@azure/search-documents 12.0.0-alpha.20230320.1 → 12.0.0-alpha.20230418.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +63 -66
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/data/searchClient.js +1 -1
- package/dist-esm/src/generated/data/searchClient.js.map +1 -1
- package/dist-esm/src/generated/data/searchClientContext.js +3 -3
- package/dist-esm/src/generated/data/searchClientContext.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClient.js +1 -1
- package/dist-esm/src/generated/service/searchServiceClient.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClientContext.js +3 -3
- package/dist-esm/src/generated/service/searchServiceClientContext.js.map +1 -1
- package/dist-esm/src/indexModels.js.map +1 -1
- package/dist-esm/src/searchClient.js +17 -20
- package/dist-esm/src/searchClient.js.map +1 -1
- package/dist-esm/src/searchIndexClient.js +40 -29
- package/dist-esm/src/searchIndexClient.js.map +1 -1
- package/dist-esm/src/searchIndexerClient.js +4 -14
- package/dist-esm/src/searchIndexerClient.js.map +1 -1
- package/package.json +3 -2
- package/types/search-documents.d.ts +1 -1
|
@@ -34,7 +34,7 @@ export class SearchClient extends coreHttpCompat.ExtendedServiceClient {
|
|
|
34
34
|
const defaults = {
|
|
35
35
|
requestContentType: "application/json; charset=utf-8"
|
|
36
36
|
};
|
|
37
|
-
const packageDetails = `azsdk-js-search-documents/
|
|
37
|
+
const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;
|
|
38
38
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
39
39
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
40
40
|
: `${packageDetails}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchClient.js","sourceRoot":"","sources":["../../../../src/generated/data/searchClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA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C,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CAGF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreHttpCompat from \"@azure/core-http-compat\";\nimport { DocumentsImpl } from \"./operations\";\nimport { Documents } from \"./operationsInterfaces\";\nimport {\n ApiVersion20210430Preview,\n SearchClientOptionalParams\n} from \"./models\";\n\n/** @internal */\nexport class SearchClient extends coreHttpCompat.ExtendedServiceClient {\n endpoint: string;\n indexName: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchClient class.\n * @param endpoint The endpoint URL of the search service.\n * @param indexName The name of the index.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n indexName: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (indexName === undefined) {\n throw new Error(\"'indexName' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-search-documents/
|
|
1
|
+
{"version":3,"file":"searchClient.js","sourceRoot":"","sources":["../../../../src/generated/data/searchClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO7C,gBAAgB;AAChB,MAAM,OAAO,YAAa,SAAQ,cAAc,CAAC,qBAAqB;IAKpE;;;;;;OAMG;IACH,YACE,QAAgB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microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreHttpCompat from \"@azure/core-http-compat\";\nimport { DocumentsImpl } from \"./operations\";\nimport { Documents } from \"./operationsInterfaces\";\nimport {\n ApiVersion20210430Preview,\n SearchClientOptionalParams\n} from \"./models\";\n\n/** @internal */\nexport class SearchClient extends coreHttpCompat.ExtendedServiceClient {\n endpoint: string;\n indexName: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchClient class.\n * @param endpoint The endpoint URL of the search service.\n * @param indexName The name of the index.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n indexName: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (indexName === undefined) {\n throw new Error(\"'indexName' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri:\n options.endpoint ??\n options.baseUri ??\n \"{endpoint}/indexes('{indexName}')\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n this.indexName = indexName;\n this.apiVersion = apiVersion;\n this.documents = new DocumentsImpl(this);\n }\n\n documents: Documents;\n}\n"]}
|
|
@@ -30,14 +30,14 @@ export class SearchClientContext extends coreClient.ServiceClient {
|
|
|
30
30
|
options = {};
|
|
31
31
|
}
|
|
32
32
|
const defaults = {
|
|
33
|
-
requestContentType: "application/json; charset=utf-8"
|
|
33
|
+
requestContentType: "application/json; charset=utf-8",
|
|
34
34
|
};
|
|
35
|
-
const packageDetails = `azsdk-js-search-documents/
|
|
35
|
+
const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;
|
|
36
36
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
37
37
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
38
38
|
: `${packageDetails}`;
|
|
39
39
|
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
|
40
|
-
userAgentPrefix
|
|
40
|
+
userAgentPrefix,
|
|
41
41
|
}, baseUri: options.endpoint || "{endpoint}/indexes('{indexName}')" });
|
|
42
42
|
super(optionsWithDefaults);
|
|
43
43
|
// Parameter assignments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchClientContext.js","sourceRoot":"","sources":["../../../../src/generated/data/searchClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"searchClientContext.js","sourceRoot":"","sources":["../../../../src/generated/data/searchClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,mBAAoB,SAAQ,UAAU,CAAC,aAAa;IAK/D;;;;;;OAMG;IACH,YACE,QAAgB,EAChB,SAAiB,EACjB,UAAqC,EACrC,OAAoC;QAEpC,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QACD,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QACD,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA+B;YAC3C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,mCAAmC,GACjE,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApiVersion20210430Preview, SearchClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class SearchClientContext extends coreClient.ServiceClient {\n endpoint: string;\n indexName: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchClientContext class.\n * @param endpoint The endpoint URL of the search service.\n * @param indexName The name of the index.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n indexName: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (indexName === undefined) {\n throw new Error(\"'indexName' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\",\n };\n\n const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n baseUri: options.endpoint || \"{endpoint}/indexes('{indexName}')\",\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n this.indexName = indexName;\n this.apiVersion = apiVersion;\n }\n}\n"]}
|
|
@@ -33,7 +33,7 @@ export class SearchServiceClient extends coreHttpCompat.ExtendedServiceClient {
|
|
|
33
33
|
const defaults = {
|
|
34
34
|
requestContentType: "application/json; charset=utf-8"
|
|
35
35
|
};
|
|
36
|
-
const packageDetails = `azsdk-js-search-documents/
|
|
36
|
+
const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;
|
|
37
37
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
38
38
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
39
39
|
: `${packageDetails}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchServiceClient.js","sourceRoot":"","sources":["../../../../src/generated/service/searchServiceClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO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WAAW,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAClB,OAA4C;QAE5C,OAAO,IAAI,CAAC,oBAAoB,CAC9B,EAAE,OAAO,EAAE,EACX,iCAAiC,CAClC,CAAC;IACJ,CAAC;CAQF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,iCAAiC,GAA6B;IAClE,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,iBAAiB;SACtC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,WAAW;SAChC;KACF;IACD,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;IACrC,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as coreHttpCompat from \"@azure/core-http-compat\";\nimport {\n DataSourcesImpl,\n IndexersImpl,\n SkillsetsImpl,\n SynonymMapsImpl,\n IndexesImpl,\n AliasesImpl\n} from \"./operations\";\nimport {\n DataSources,\n Indexers,\n Skillsets,\n SynonymMaps,\n Indexes,\n Aliases\n} from \"./operationsInterfaces\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport {\n ApiVersion20210430Preview,\n SearchServiceClientOptionalParams,\n GetServiceStatisticsOptionalParams,\n GetServiceStatisticsResponse\n} from \"./models\";\n\n/** @internal */\nexport class SearchServiceClient extends coreHttpCompat.ExtendedServiceClient {\n endpoint: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchServiceClient class.\n * @param endpoint The endpoint URL of the search service.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchServiceClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchServiceClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-search-documents/
|
|
1
|
+
{"version":3,"file":"searchServiceClient.js","sourceRoot":"","sources":["../../../../src/generated/service/searchServiceClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACZ,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAQ5C,gBAAgB;AAChB,MAAM,OAAO,mBAAo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Ae,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAClB,OAA4C;QAE5C,OAAO,IAAI,CAAC,oBAAoB,CAC9B,EAAE,OAAO,EAAE,EACX,iCAAiC,CAClC,CAAC;IACJ,CAAC;CAQF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,iCAAiC,GAA6B;IAClE,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,iBAAiB;SACtC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,WAAW;SAChC;KACF;IACD,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;IACrC,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as coreHttpCompat from \"@azure/core-http-compat\";\nimport {\n DataSourcesImpl,\n IndexersImpl,\n SkillsetsImpl,\n SynonymMapsImpl,\n IndexesImpl,\n AliasesImpl\n} from \"./operations\";\nimport {\n DataSources,\n Indexers,\n Skillsets,\n SynonymMaps,\n Indexes,\n Aliases\n} from \"./operationsInterfaces\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport {\n ApiVersion20210430Preview,\n SearchServiceClientOptionalParams,\n GetServiceStatisticsOptionalParams,\n GetServiceStatisticsResponse\n} from \"./models\";\n\n/** @internal */\nexport class SearchServiceClient extends coreHttpCompat.ExtendedServiceClient {\n endpoint: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchServiceClient class.\n * @param endpoint The endpoint URL of the search service.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchServiceClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchServiceClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint ?? options.baseUri ?? \"{endpoint}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n this.apiVersion = apiVersion;\n this.dataSources = new DataSourcesImpl(this);\n this.indexers = new IndexersImpl(this);\n this.skillsets = new SkillsetsImpl(this);\n this.synonymMaps = new SynonymMapsImpl(this);\n this.indexes = new IndexesImpl(this);\n this.aliases = new AliasesImpl(this);\n }\n\n /**\n * Gets service level statistics for a search service.\n * @param options The options parameters.\n */\n getServiceStatistics(\n options?: GetServiceStatisticsOptionalParams\n ): Promise<GetServiceStatisticsResponse> {\n return this.sendOperationRequest(\n { options },\n getServiceStatisticsOperationSpec\n );\n }\n\n dataSources: DataSources;\n indexers: Indexers;\n skillsets: Skillsets;\n synonymMaps: SynonymMaps;\n indexes: Indexes;\n aliases: Aliases;\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst getServiceStatisticsOperationSpec: coreClient.OperationSpec = {\n path: \"/servicestats\",\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.ServiceStatistics\n },\n default: {\n bodyMapper: Mappers.SearchError\n }\n },\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [Parameters.accept],\n serializer\n};\n"]}
|
|
@@ -26,14 +26,14 @@ export class SearchServiceClientContext extends coreClient.ServiceClient {
|
|
|
26
26
|
options = {};
|
|
27
27
|
}
|
|
28
28
|
const defaults = {
|
|
29
|
-
requestContentType: "application/json; charset=utf-8"
|
|
29
|
+
requestContentType: "application/json; charset=utf-8",
|
|
30
30
|
};
|
|
31
|
-
const packageDetails = `azsdk-js-search-documents/
|
|
31
|
+
const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;
|
|
32
32
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
33
33
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
34
34
|
: `${packageDetails}`;
|
|
35
35
|
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
|
36
|
-
userAgentPrefix
|
|
36
|
+
userAgentPrefix,
|
|
37
37
|
}, baseUri: options.endpoint || "{endpoint}" });
|
|
38
38
|
super(optionsWithDefaults);
|
|
39
39
|
// Parameter assignments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchServiceClientContext.js","sourceRoot":"","sources":["../../../../src/generated/service/searchServiceClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"searchServiceClientContext.js","sourceRoot":"","sources":["../../../../src/generated/service/searchServiceClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,UAAU,CAAC,aAAa;IAItE;;;;;OAKG;IACH,YACE,QAAgB,EAChB,UAAqC,EACrC,OAA2C;QAE3C,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QACD,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAsC;YAClD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,YAAY,GAC1C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApiVersion20210430Preview, SearchServiceClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class SearchServiceClientContext extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: ApiVersion20210430Preview;\n\n /**\n * Initializes a new instance of the SearchServiceClientContext class.\n * @param endpoint The endpoint URL of the search service.\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n endpoint: string,\n apiVersion: ApiVersion20210430Preview,\n options?: SearchServiceClientOptionalParams\n ) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SearchServiceClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\",\n };\n\n const packageDetails = `azsdk-js-search-documents/12.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n baseUri: options.endpoint || \"{endpoint}\",\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n this.apiVersion = apiVersion;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexModels.js","sourceRoot":"","sources":["../../src/indexModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\nimport {\n AnswerResult,\n Answers,\n AutocompleteMode,\n CaptionResult,\n Captions,\n FacetResult,\n IndexActionType,\n QueryAnswerType,\n QueryCaptionType,\n QueryLanguage,\n QuerySpellerType,\n QueryType,\n ScoringStatistics,\n SearchMode,\n Speller,\n} from \"./generated/data/models\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport GeographyPoint from \"./geographyPoint\";\n\n/**\n * Options for performing the count operation on the index.\n */\nexport type CountDocumentsOptions = OperationOptions;\n\n/**\n * Options for SearchIndexingBufferedSender.\n */\nexport interface SearchIndexingBufferedSenderOptions {\n /**\n * Indicates if autoFlush is enabled.\n */\n autoFlush?: boolean;\n /**\n * Initial Batch Action Count.\n *\n * A batch request will be sent once the documents\n * reach the initialBatchActionCount.\n */\n initialBatchActionCount?: number;\n /**\n * Flush Window.\n *\n * A batch request will be sent after flushWindowInMs is\n * reached.\n */\n flushWindowInMs?: number;\n /**\n * Maximum number of Retries\n */\n maxRetriesPerAction?: number;\n /**\n * Delay between retries\n */\n throttlingDelayInMs?: number;\n /**\n * Max Delay between retries\n */\n maxThrottlingDelayInMs?: number;\n}\n\n/**\n * Options for SearchIndexingBufferedSenderUploadDocuments.\n */\nexport type SearchIndexingBufferedSenderUploadDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderMergeDocuments.\n */\nexport type SearchIndexingBufferedSenderMergeDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderMergeOrUploadDocuments.\n */\nexport type SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderDeleteDocuments.\n */\nexport type SearchIndexingBufferedSenderDeleteDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderFlushDocuments.\n */\nexport type SearchIndexingBufferedSenderFlushDocumentsOptions = OperationOptions;\n\n/**\n * Options for retrieving a single document.\n */\nexport interface GetDocumentOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends OperationOptions {\n /**\n * List of field names to retrieve for the document; Any field not retrieved will be missing from\n * the returned document.\n */\n selectedFields?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n}\n\n/**\n * Options for the modify index batch operation.\n */\nexport interface IndexDocumentsOptions extends OperationOptions {\n /**\n * If true, will cause this operation to throw if any document operation\n * in the batch did not succeed.\n */\n throwOnAnyFailure?: boolean;\n}\n\n/**\n * Options for the upload documents operation.\n */\nexport type UploadDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the merge documents operation.\n */\nexport type MergeDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the merge or upload documents operation.\n */\nexport type MergeOrUploadDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the delete documents operation.\n */\nexport type DeleteDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Arguments for retrieving the next page of search results.\n */\nexport interface ListSearchResultsPageSettings {\n /**\n * A token used for retrieving the next page of results when the server\n * enforces pagination.\n */\n continuationToken?: string;\n}\n\n// BEGIN manually modified generated interfaces\n//\n// This section is for places where we have to manually fix issues\n// with interfaces from the generated code.\n// Mostly this is to allow modeling additionalProperties:true as generics.\n\n/**\n * Options for retrieving completion text for a partial searchText.\n */\nexport type AutocompleteOptions<Model extends object> = OperationOptions &\n AutocompleteRequest<Model>;\n/**\n * Options for committing a full search request.\n */\nexport type SearchOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = OperationOptions & SearchRequestOptions<Model, Fields>;\n/**\n * Options for retrieving suggestions based on the searchText.\n */\nexport type SuggestOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = OperationOptions & SuggestRequest<Model, Fields>;\n\n/**\n * An iterator for search results of a paticular query. Will make requests\n * as needed during iteration. Use .byPage() to make one request to the server\n * per iteration.\n */\nexport type SearchIterator<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = PagedAsyncIterableIterator<\n SearchResult<Model, Fields>,\n SearchDocumentsPageResult<Model, Fields>,\n ListSearchResultsPageSettings\n>;\n\n/**\n * Parameters for filtering, sorting, faceting, paging, and other search query behaviors.\n */\nexport interface SearchRequest {\n /**\n * A value that specifies whether to fetch the total count of results. Default is false. Setting\n * this value to true may have a performance impact. Note that the count returned is an\n * approximation.\n */\n includeTotalCount?: boolean;\n /**\n * The list of facet expressions to apply to the search query. Each facet expression contains a\n * field name, optionally followed by a comma-separated list of name:value pairs.\n */\n facets?: string[];\n /**\n * The OData $filter expression to apply to the search query.\n */\n filter?: string;\n /**\n * The comma-separated list of field names to use for hit highlights. Only searchable fields can\n * be used for hit highlighting.\n */\n highlightFields?: string;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is\n * </em>.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default\n * is <em>.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * search query in order for the query to be reported as a success. This parameter can be useful\n * for ensuring search availability even for services with only one replica. The default is 100.\n */\n minimumCoverage?: number;\n /**\n * The comma-separated list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string;\n /**\n * A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if\n * your query uses the Lucene query syntax. Possible values include: 'Simple', 'Full'\n */\n queryType?: QueryType;\n /**\n * A value that specifies whether we want to calculate scoring statistics (such as document\n * frequency) globally for more consistent scoring, or locally, for lower latency. The default is\n * 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global\n * scoring statistics can increase latency of search queries. Possible values include: 'Local',\n * 'Global'\n */\n scoringStatistics?: ScoringStatistics;\n /**\n * A value to be used to create a sticky session, which can help getting more consistent results.\n * As long as the same sessionId is used, a best-effort attempt will be made to target the same\n * replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the\n * load balancing of the requests across replicas and adversely affect the performance of the\n * search service. The value used as sessionId cannot start with a '_' character.\n */\n sessionId?: string;\n /**\n * The list of parameter values to be used in scoring functions (for example,\n * referencePointParameter) using the format name-values. For example, if the scoring profile\n * defines a function with a parameter called 'mylocation' the parameter string would be\n * \"mylocation--122.2,44.8\" (without the quotes).\n */\n scoringParameters?: string[];\n /**\n * The name of a scoring profile to evaluate match scores for matching documents in order to sort\n * the results.\n */\n scoringProfile?: string;\n /**\n * The name of a semantic configuration that will be used when processing documents for queries of\n * type semantic.\n */\n semanticConfiguration?: string;\n /**\n * A full-text search query expression; Use \"*\" or omit this parameter to match all documents.\n */\n searchText?: string;\n /**\n * The comma-separated list of field names to which to scope the full-text search. When using\n * fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each\n * fielded search expression take precedence over any field names listed in this parameter.\n */\n searchFields?: string;\n /**\n * A value that specifies whether any or all of the search terms must be matched in order to\n * count the document as a match. Possible values include: 'Any', 'All'\n */\n searchMode?: SearchMode;\n /**\n * A value that specifies the language of the search query.\n */\n queryLanguage?: QueryLanguage;\n /**\n * A value that specified the type of the speller to use to spell-correct individual search\n * query terms.\n */\n speller?: QuerySpellerType;\n /**\n * A value that specifies whether answers should be returned as part of the search response.\n */\n answers?: QueryAnswerType;\n /**\n * The comma-separated list of fields to retrieve. If unspecified, all fields marked as\n * retrievable in the schema are included.\n */\n select?: string;\n /**\n * The number of search results to skip. This value cannot be greater than 100,000. If you need\n * to scan documents in sequence, but cannot use skip due to this limitation, consider using\n * orderby on a totally-ordered key and filter with a range query instead.\n */\n skip?: number;\n /**\n * The number of search results to retrieve. This can be used in conjunction with $skip to\n * implement client-side paging of search results. If results are truncated due to server-side\n * paging, the response will include a continuation token that can be used to issue another\n * Search request for the next page of results.\n */\n top?: number;\n /**\n * A value that specifies whether captions should be returned as part of the search response.\n */\n captions?: QueryCaptionType;\n /**\n * The comma-separated list of field names used for semantic search.\n */\n semanticFields?: string;\n}\n\n/**\n * Parameters for filtering, sorting, faceting, paging, and other search query behaviors.\n */\nexport interface SearchRequestOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * A value that specifies whether to fetch the total count of results. Default is false. Setting\n * this value to true may have a performance impact. Note that the count returned is an\n * approximation.\n */\n includeTotalCount?: boolean;\n /**\n * The list of facet expressions to apply to the search query. Each facet expression contains a\n * field name, optionally followed by a comma-separated list of name:value pairs.\n */\n facets?: string[];\n /**\n * The OData $filter expression to apply to the search query.\n */\n filter?: string;\n /**\n * The comma-separated list of field names to use for hit highlights. Only searchable fields can\n * be used for hit highlighting.\n */\n highlightFields?: string;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is\n * </em>.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default\n * is <em>.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * search query in order for the query to be reported as a success. This parameter can be useful\n * for ensuring search availability even for services with only one replica. The default is 100.\n */\n minimumCoverage?: number;\n /**\n * The list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string[];\n /**\n * A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if\n * your query uses the Lucene query syntax. Possible values include: 'simple', 'full'\n */\n queryType?: QueryType;\n /**\n * The list of parameter values to be used in scoring functions (for example,\n * referencePointParameter) using the format name-values. For example, if the scoring profile\n * defines a function with a parameter called 'mylocation' the parameter string would be\n * \"mylocation--122.2,44.8\" (without the quotes).\n */\n scoringParameters?: string[];\n /**\n * The name of a scoring profile to evaluate match scores for matching documents in order to sort\n * the results.\n */\n scoringProfile?: string;\n /**\n * The comma-separated list of field names to which to scope the full-text search. When using\n * fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each\n * fielded search expression take precedence over any field names listed in this parameter.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The language of the query.\n */\n queryLanguage?: QueryLanguage;\n /**\n * Improve search recall by spell-correcting individual search query terms.\n */\n speller?: Speller;\n /**\n * This parameter is only valid if the query type is 'semantic'. If set, the query returns answers\n * extracted from key passages in the highest ranked documents. The number of answers returned can\n * be configured by appending the pipe character '|' followed by the 'count-\\<number of answers\\>' option\n * after the answers parameter value, such as 'extractive|count-3'. Default count is 1.\n */\n answers?: Answers;\n /**\n * A value that specifies whether any or all of the search terms must be matched in order to\n * count the document as a match. Possible values include: 'any', 'all'\n */\n searchMode?: SearchMode;\n /**\n * A value that specifies whether we want to calculate scoring statistics (such as document\n * frequency) globally for more consistent scoring, or locally, for lower latency. Possible\n * values include: 'Local', 'Global'\n */\n scoringStatistics?: ScoringStatistics;\n /**\n * A value to be used to create a sticky session, which can help to get more consistent results.\n * As long as the same sessionId is used, a best-effort attempt will be made to target the same\n * replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the\n * load balancing of the requests across replicas and adversely affect the performance of the\n * search service. The value used as sessionId cannot start with a '_' character.\n */\n sessionId?: string;\n /**\n * The list of fields to retrieve. If unspecified, all fields marked as\n * retrievable in the schema are included.\n */\n select?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n /**\n * The number of search results to skip. This value cannot be greater than 100,000. If you need\n * to scan documents in sequence, but cannot use skip due to this limitation, consider using\n * orderby on a totally-ordered key and filter with a range query instead.\n */\n skip?: number;\n /**\n * The number of search results to retrieve. This can be used in conjunction with $skip to\n * implement client-side paging of search results. If results are truncated due to server-side\n * paging, the response will include a continuation token that can be used to issue another\n * Search request for the next page of results.\n */\n top?: number;\n /**\n * This parameter is only valid if the query type is 'semantic'. If set, the query returns captions\n * extracted from key passages in the highest ranked documents. When Captions is set to 'extractive',\n * highlighting is enabled by default, and can be configured by appending the pipe character '|'\n * followed by the 'highlight-true'/'highlight-false' option, such as 'extractive|highlight-true'. Defaults to 'None'.\n */\n captions?: Captions;\n /**\n * The list of field names used for semantic search.\n */\n semanticFields?: string[];\n}\n\n/**\n * Contains a document found by a search query, plus associated metadata.\n */\nexport type SearchResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = {\n /**\n * The relevance score of the document compared to other documents returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly score: number;\n /**\n * The relevance score computed by the semantic ranker for the top search results. Search results are sorted by the RerankerScore first and then by the Score. RerankerScore is only returned for queries of type 'semantic'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly rerankerScore?: number;\n /**\n * Text fragments from the document that indicate the matching search terms, organized by each\n * applicable field; null if hit highlighting was not enabled for the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly highlights?: { [k in SelectFields<Model>]?: string[] };\n /**\n * Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly captions?: CaptionResult[];\n\n document: NarrowedModel<Model, Fields>;\n};\n\n/**\n * Response containing search results from an index.\n */\nexport interface SearchDocumentsResultBase {\n /**\n * The total count of results found by the search operation, or null if the count was not\n * requested. If present, the count may be greater than the number of results in this response.\n * This can happen if you use the $top or $skip parameters, or if Azure Cognitive Search can't\n * return all the requested documents in a single Search response.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly count?: number;\n /**\n * A value indicating the percentage of the index that was included in the query, or null if\n * minimumCoverage was not specified in the request.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly coverage?: number;\n /**\n * The facet query results for the search operation, organized as a collection of buckets for\n * each faceted field; null if the query did not include any facet expressions.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly facets?: { [propertyName: string]: FacetResult[] };\n /**\n * The answers query results for the search operation; null if the answers query parameter was\n * not specified or set to 'none'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly answers?: AnswerResult[];\n}\n\n/**\n * Response containing search results from an index.\n */\nexport interface SearchDocumentsResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends SearchDocumentsResultBase {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SearchIterator<Model, Fields>;\n}\n\n/**\n * Response containing search page results from an index.\n */\nexport interface SearchDocumentsPageResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends SearchDocumentsResultBase {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SearchResult<Model, Fields>[];\n /**\n * A token used for retrieving the next page of results when the server\n * enforces pagination.\n */\n continuationToken?: string;\n}\n\n/**\n * Parameters for filtering, sorting, fuzzy matching, and other suggestions query behaviors.\n */\nexport interface SuggestRequest<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * An OData expression that filters the documents considered for suggestions.\n */\n filter?: string;\n /**\n * A value indicating whether to use fuzzy matching for the suggestion query. Default is false.\n * When set to true, the query will find suggestions even if there's a substituted or missing\n * character in the search text. While this provides a better experience in some scenarios, it\n * comes at a performance cost as fuzzy suggestion searches are slower and consume more\n * resources.\n */\n useFuzzyMatching?: boolean;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,\n * hit highlighting of suggestions is disabled.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If\n * omitted, hit highlighting of suggestions is disabled.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * suggestion query in order for the query to be reported as a success. This parameter can be\n * useful for ensuring search availability even for services with only one replica. The default\n * is 80.\n */\n minimumCoverage?: number;\n /**\n * The list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string[];\n /**\n * The comma-separated list of field names to search for the specified search text. Target fields\n * must be included in the specified suggester.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The list of fields to retrieve. If unspecified, only the key field will be\n * included in the results.\n */\n select?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n /**\n /**\n * The number of suggestions to retrieve. This must be a value between 1 and 100. The default is\n * 5.\n */\n top?: number;\n}\n\n/**\n * A result containing a document found by a suggestion query, plus associated metadata.\n */\nexport type SuggestResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = {\n /**\n * The text of the suggestion result.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly text: string;\n document: SuggestNarrowedModel<Model, Fields>;\n};\n\n/**\n * Response containing suggestion query results from an index.\n */\nexport interface SuggestDocumentsResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SuggestResult<Model, Fields>[];\n /**\n * A value indicating the percentage of the index that was included in the query, or null if\n * minimumCoverage was not set in the request.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly coverage?: number;\n}\n\n/**\n * Parameters for fuzzy matching, and other autocomplete query behaviors.\n */\nexport interface AutocompleteRequest<Model extends object> {\n /**\n * Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles\n * and 'oneTermWithContext' to use the current context while producing auto-completed terms.\n * Possible values include: 'oneTerm', 'twoTerms', 'oneTermWithContext'\n */\n autocompleteMode?: AutocompleteMode;\n /**\n * An OData expression that filters the documents used to produce completed terms for the\n * Autocomplete result.\n */\n filter?: string;\n /**\n * A value indicating whether to use fuzzy matching for the autocomplete query. Default is false.\n * When set to true, the query will autocomplete terms even if there's a substituted or missing\n * character in the search text. While this provides a better experience in some scenarios, it\n * comes at a performance cost as fuzzy autocomplete queries are slower and consume more\n * resources.\n */\n useFuzzyMatching?: boolean;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,\n * hit highlighting is disabled.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If\n * omitted, hit highlighting is disabled.availability\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by an\n * autocomplete query in order for the query to be reported as a success. This parameter can be\n * useful for ensuring search availability even for services with only one replica. The default\n * is 80.\n */\n minimumCoverage?: number;\n /**\n * The comma-separated list of field names to consider when querying for auto-completed terms.\n * Target fields must be included in the specified suggester.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The number of auto-completed terms to retrieve. This must be a value between 1 and 100. The\n * default is 5.\n */\n top?: number;\n}\n\n/**\n * Represents an index action that operates on a document.\n */\nexport type IndexDocumentsAction<T> = {\n /**\n * The operation to perform on a document in an indexing batch. Possible values include:\n * 'upload', 'merge', 'mergeOrUpload', 'delete'\n */\n __actionType: IndexActionType;\n} & Partial<T>;\n\n// END manually modified generated interfaces\n\n// Utility types\n\nexport type UnionToIntersection<U> =\n // Distribute members of U into parameter position of a union of functions\n (\n U extends unknown ? (_: U) => unknown : never\n ) extends // Infer the intersection of the members of U as a single intersected parameter type\n (_: infer I) => unknown\n ? I\n : never;\n\n// Types that should not be included in SelectFields recursion\nexport type ExcludedODataTypes = Date | GeographyPoint;\n\n/**\n * Produces a union of valid Cognitive Search OData $select paths for T\n * using a post-order traversal of the field tree rooted at T.\n */\nexport type SelectFields<T extends object> = T extends Array<infer Elem>\n ? // Allow selecting fields only from elements which are objects\n Elem extends object\n ? SelectFields<Elem>\n : never\n : {\n // Only consider string keys\n [Key in keyof T]: Key extends string\n ? NonNullable<T[Key]> extends object\n ? NonNullable<T[Key]> extends ExcludedODataTypes\n ? // Excluded, so don't recur\n Key\n : SelectFields<NonNullable<T[Key]>> extends infer NextPaths\n ? // Narrow NextPaths' type for template literal\n NextPaths extends string\n ? // Union this key with all the next paths separated with '/'\n Key | `${Key}/${NextPaths}`\n : // We didn't infer any nested paths, so just use this key\n Key\n : never\n : // Not an object, so can't recur\n Key\n : never;\n }[keyof T & string] &\n // Filter out undefined properties\n string;\n\n/**\n * Deeply pick fields of T using valid Cognitive Search OData $select\n * paths.\n */\nexport type SearchPick<T extends object, Paths extends SelectFields<T>> =\n // The default behavior of a client with no model is to return an object type\n [T] extends [never]\n ? object\n : // We're going to get a union of individual interfaces for each field in T that's selected, so convert that to an intersection.\n UnionToIntersection<\n // Paths is a union or single string type, so if it's a union it will be _distributed_ over this conditional.\n // Fortunately, template literal types are not greedy, so we can infer the field name easily.\n Paths extends `${infer FieldName}/${infer RestPaths}`\n ? // Symbols and numbers are invalid types for field names\n FieldName extends keyof T & string\n ? NonNullable<T[FieldName]> extends Array<infer Elem>\n ? Elem extends object\n ? // Extends clause is necessary to refine the constraint of RestPaths\n RestPaths extends SelectFields<Elem>\n ? // Narrow the type of every element in the array\n {\n [Key in keyof T as Key & FieldName]: Array<SearchPick<Elem, RestPaths>>;\n }\n : // Unreachable by construction\n never\n : // Don't recur on arrays of non-object types\n never\n : NonNullable<T[FieldName]> extends object\n ? // Recur :)\n {\n [Key in keyof T as Key & FieldName]: RestPaths extends SelectFields<\n T[Key] & {\n // This empty intersection fixes `T[Key]` not being narrowed to an object type in older versions of TS\n }\n >\n ?\n | SearchPick<\n T[Key] & {\n // Ditto\n },\n RestPaths\n >\n | Extract<T[Key], null>\n : // Unreachable by construction\n never;\n }\n : // Unreachable by construction\n never\n : // Ignore symbols and numbers\n never\n : // Otherwise, capture the paths that are simple keys of T itself\n Pick<T, Paths> | Extract<T, null>\n > & {\n // This useless intersection actually prevents the TypeScript language server from\n // expanding the definition of SearchPick<T, Paths> in IntelliSense. Since we're\n // sure the type always yields an object, this intersection does not alter the type\n // at all, only the display string of the type.\n };\n\nexport type ExtractDocumentKey<Model> = {\n [K in keyof Model as Model[K] extends string | undefined ? K : never]: Model[K];\n};\n\nexport type NarrowedModel<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> =\n // Avoid calculating the type if every field is specified\n SelectFields<Model> extends Fields ? Model : SearchPick<Model, Fields>;\n\nexport type SuggestNarrowedModel<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = [Model] extends [never]\n ? // The client was instantiated with no model, so the narrowest possible result type is `object`\n object\n : // null represents the default case (no fields specified as selected)\n [Fields] extends [never]\n ? // Filter nullable (i.e. non-key) properties from the model, as they're not returned by the service by default\n keyof ExtractDocumentKey<Model> extends never\n ? // Return the original model if none of the properties are non-nullable\n Model\n : ExtractDocumentKey<Model>\n : // Fields isn't narrowed to exclude null by the first condition, so it needs to be narrowed here\n Fields extends SelectFields<Model>\n ? NarrowedModel<Model, Fields>\n : // Unreachable by construction\n never;\n"]}
|
|
1
|
+
{"version":3,"file":"indexModels.js","sourceRoot":"","sources":["../../src/indexModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\nimport {\n AnswerResult,\n Answers,\n AutocompleteMode,\n CaptionResult,\n Captions,\n FacetResult,\n IndexActionType,\n QueryAnswerType,\n QueryCaptionType,\n QueryLanguage,\n QuerySpellerType,\n QueryType,\n ScoringStatistics,\n SearchMode,\n Speller,\n} from \"./generated/data/models\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport GeographyPoint from \"./geographyPoint\";\n\n/**\n * Options for performing the count operation on the index.\n */\nexport type CountDocumentsOptions = OperationOptions;\n\n/**\n * Options for SearchIndexingBufferedSender.\n */\nexport interface SearchIndexingBufferedSenderOptions {\n /**\n * Indicates if autoFlush is enabled.\n */\n autoFlush?: boolean;\n /**\n * Initial Batch Action Count.\n *\n * A batch request will be sent once the documents\n * reach the initialBatchActionCount.\n */\n initialBatchActionCount?: number;\n /**\n * Flush Window.\n *\n * A batch request will be sent after flushWindowInMs is\n * reached.\n */\n flushWindowInMs?: number;\n /**\n * Maximum number of Retries\n */\n maxRetriesPerAction?: number;\n /**\n * Delay between retries\n */\n throttlingDelayInMs?: number;\n /**\n * Max Delay between retries\n */\n maxThrottlingDelayInMs?: number;\n}\n\n/**\n * Options for SearchIndexingBufferedSenderUploadDocuments.\n */\nexport type SearchIndexingBufferedSenderUploadDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderMergeDocuments.\n */\nexport type SearchIndexingBufferedSenderMergeDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderMergeOrUploadDocuments.\n */\nexport type SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderDeleteDocuments.\n */\nexport type SearchIndexingBufferedSenderDeleteDocumentsOptions = OperationOptions;\n/**\n * Options for SearchIndexingBufferedSenderFlushDocuments.\n */\nexport type SearchIndexingBufferedSenderFlushDocumentsOptions = OperationOptions;\n\n/**\n * Options for retrieving a single document.\n */\nexport interface GetDocumentOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends OperationOptions {\n /**\n * List of field names to retrieve for the document; Any field not retrieved will be missing from\n * the returned document.\n */\n selectedFields?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n}\n\n/**\n * Options for the modify index batch operation.\n */\nexport interface IndexDocumentsOptions extends OperationOptions {\n /**\n * If true, will cause this operation to throw if any document operation\n * in the batch did not succeed.\n */\n throwOnAnyFailure?: boolean;\n}\n\n/**\n * Options for the upload documents operation.\n */\nexport type UploadDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the merge documents operation.\n */\nexport type MergeDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the merge or upload documents operation.\n */\nexport type MergeOrUploadDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Options for the delete documents operation.\n */\nexport type DeleteDocumentsOptions = IndexDocumentsOptions;\n\n/**\n * Arguments for retrieving the next page of search results.\n */\nexport interface ListSearchResultsPageSettings {\n /**\n * A token used for retrieving the next page of results when the server\n * enforces pagination.\n */\n continuationToken?: string;\n}\n\n// BEGIN manually modified generated interfaces\n//\n// This section is for places where we have to manually fix issues\n// with interfaces from the generated code.\n// Mostly this is to allow modeling additionalProperties:true as generics.\n\n/**\n * Options for retrieving completion text for a partial searchText.\n */\nexport type AutocompleteOptions<Model extends object> = OperationOptions &\n AutocompleteRequest<Model>;\n/**\n * Options for committing a full search request.\n */\nexport type SearchOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = OperationOptions & SearchRequestOptions<Model, Fields>;\n/**\n * Options for retrieving suggestions based on the searchText.\n */\nexport type SuggestOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = OperationOptions & SuggestRequest<Model, Fields>;\n\n/**\n * An iterator for search results of a paticular query. Will make requests\n * as needed during iteration. Use .byPage() to make one request to the server\n * per iteration.\n */\nexport type SearchIterator<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = PagedAsyncIterableIterator<\n SearchResult<Model, Fields>,\n SearchDocumentsPageResult<Model, Fields>,\n ListSearchResultsPageSettings\n>;\n\n/**\n * Parameters for filtering, sorting, faceting, paging, and other search query behaviors.\n */\nexport interface SearchRequest {\n /**\n * A value that specifies whether to fetch the total count of results. Default is false. Setting\n * this value to true may have a performance impact. Note that the count returned is an\n * approximation.\n */\n includeTotalCount?: boolean;\n /**\n * The list of facet expressions to apply to the search query. Each facet expression contains a\n * field name, optionally followed by a comma-separated list of name:value pairs.\n */\n facets?: string[];\n /**\n * The OData $filter expression to apply to the search query.\n */\n filter?: string;\n /**\n * The comma-separated list of field names to use for hit highlights. Only searchable fields can\n * be used for hit highlighting.\n */\n highlightFields?: string;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is\n * </em>.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default\n * is <em>.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * search query in order for the query to be reported as a success. This parameter can be useful\n * for ensuring search availability even for services with only one replica. The default is 100.\n */\n minimumCoverage?: number;\n /**\n * The comma-separated list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string;\n /**\n * A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if\n * your query uses the Lucene query syntax. Possible values include: 'Simple', 'Full'\n */\n queryType?: QueryType;\n /**\n * A value that specifies whether we want to calculate scoring statistics (such as document\n * frequency) globally for more consistent scoring, or locally, for lower latency. The default is\n * 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global\n * scoring statistics can increase latency of search queries. Possible values include: 'Local',\n * 'Global'\n */\n scoringStatistics?: ScoringStatistics;\n /**\n * A value to be used to create a sticky session, which can help getting more consistent results.\n * As long as the same sessionId is used, a best-effort attempt will be made to target the same\n * replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the\n * load balancing of the requests across replicas and adversely affect the performance of the\n * search service. The value used as sessionId cannot start with a '_' character.\n */\n sessionId?: string;\n /**\n * The list of parameter values to be used in scoring functions (for example,\n * referencePointParameter) using the format name-values. For example, if the scoring profile\n * defines a function with a parameter called 'mylocation' the parameter string would be\n * \"mylocation--122.2,44.8\" (without the quotes).\n */\n scoringParameters?: string[];\n /**\n * The name of a scoring profile to evaluate match scores for matching documents in order to sort\n * the results.\n */\n scoringProfile?: string;\n /**\n * The name of a semantic configuration that will be used when processing documents for queries of\n * type semantic.\n */\n semanticConfiguration?: string;\n /**\n * A full-text search query expression; Use \"*\" or omit this parameter to match all documents.\n */\n searchText?: string;\n /**\n * The comma-separated list of field names to which to scope the full-text search. When using\n * fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each\n * fielded search expression take precedence over any field names listed in this parameter.\n */\n searchFields?: string;\n /**\n * A value that specifies whether any or all of the search terms must be matched in order to\n * count the document as a match. Possible values include: 'Any', 'All'\n */\n searchMode?: SearchMode;\n /**\n * A value that specifies the language of the search query.\n */\n queryLanguage?: QueryLanguage;\n /**\n * A value that specified the type of the speller to use to spell-correct individual search\n * query terms.\n */\n speller?: QuerySpellerType;\n /**\n * A value that specifies whether answers should be returned as part of the search response.\n */\n answers?: QueryAnswerType;\n /**\n * The comma-separated list of fields to retrieve. If unspecified, all fields marked as\n * retrievable in the schema are included.\n */\n select?: string;\n /**\n * The number of search results to skip. This value cannot be greater than 100,000. If you need\n * to scan documents in sequence, but cannot use skip due to this limitation, consider using\n * orderby on a totally-ordered key and filter with a range query instead.\n */\n skip?: number;\n /**\n * The number of search results to retrieve. This can be used in conjunction with $skip to\n * implement client-side paging of search results. If results are truncated due to server-side\n * paging, the response will include a continuation token that can be used to issue another\n * Search request for the next page of results.\n */\n top?: number;\n /**\n * A value that specifies whether captions should be returned as part of the search response.\n */\n captions?: QueryCaptionType;\n /**\n * The comma-separated list of field names used for semantic search.\n */\n semanticFields?: string;\n}\n\n/**\n * Parameters for filtering, sorting, faceting, paging, and other search query behaviors.\n */\nexport interface SearchRequestOptions<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * A value that specifies whether to fetch the total count of results. Default is false. Setting\n * this value to true may have a performance impact. Note that the count returned is an\n * approximation.\n */\n includeTotalCount?: boolean;\n /**\n * The list of facet expressions to apply to the search query. Each facet expression contains a\n * field name, optionally followed by a comma-separated list of name:value pairs.\n */\n facets?: string[];\n /**\n * The OData $filter expression to apply to the search query.\n */\n filter?: string;\n /**\n * The comma-separated list of field names to use for hit highlights. Only searchable fields can\n * be used for hit highlighting.\n */\n highlightFields?: string;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is\n * </em>.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default\n * is <em>.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * search query in order for the query to be reported as a success. This parameter can be useful\n * for ensuring search availability even for services with only one replica. The default is 100.\n */\n minimumCoverage?: number;\n /**\n * The list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string[];\n /**\n * A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if\n * your query uses the Lucene query syntax. Possible values include: 'simple', 'full'\n */\n queryType?: QueryType;\n /**\n * The list of parameter values to be used in scoring functions (for example,\n * referencePointParameter) using the format name-values. For example, if the scoring profile\n * defines a function with a parameter called 'mylocation' the parameter string would be\n * \"mylocation--122.2,44.8\" (without the quotes).\n */\n scoringParameters?: string[];\n /**\n * The name of a scoring profile to evaluate match scores for matching documents in order to sort\n * the results.\n */\n scoringProfile?: string;\n /**\n * The comma-separated list of field names to which to scope the full-text search. When using\n * fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each\n * fielded search expression take precedence over any field names listed in this parameter.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The language of the query.\n */\n queryLanguage?: QueryLanguage;\n /**\n * Improve search recall by spell-correcting individual search query terms.\n */\n speller?: Speller;\n /**\n * This parameter is only valid if the query type is 'semantic'. If set, the query returns answers\n * extracted from key passages in the highest ranked documents. The number of answers returned can\n * be configured by appending the pipe character '|' followed by the 'count-\\<number of answers\\>' option\n * after the answers parameter value, such as 'extractive|count-3'. Default count is 1.\n */\n answers?: Answers;\n /**\n * A value that specifies whether any or all of the search terms must be matched in order to\n * count the document as a match. Possible values include: 'any', 'all'\n */\n searchMode?: SearchMode;\n /**\n * A value that specifies whether we want to calculate scoring statistics (such as document\n * frequency) globally for more consistent scoring, or locally, for lower latency. Possible\n * values include: 'Local', 'Global'\n */\n scoringStatistics?: ScoringStatistics;\n /**\n * A value to be used to create a sticky session, which can help to get more consistent results.\n * As long as the same sessionId is used, a best-effort attempt will be made to target the same\n * replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the\n * load balancing of the requests across replicas and adversely affect the performance of the\n * search service. The value used as sessionId cannot start with a '_' character.\n */\n sessionId?: string;\n /**\n * The list of fields to retrieve. If unspecified, all fields marked as\n * retrievable in the schema are included.\n */\n select?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n /**\n * The number of search results to skip. This value cannot be greater than 100,000. If you need\n * to scan documents in sequence, but cannot use skip due to this limitation, consider using\n * orderby on a totally-ordered key and filter with a range query instead.\n */\n skip?: number;\n /**\n * The number of search results to retrieve. This can be used in conjunction with $skip to\n * implement client-side paging of search results. If results are truncated due to server-side\n * paging, the response will include a continuation token that can be used to issue another\n * Search request for the next page of results.\n */\n top?: number;\n /**\n * This parameter is only valid if the query type is 'semantic'. If set, the query returns captions\n * extracted from key passages in the highest ranked documents. When Captions is set to 'extractive',\n * highlighting is enabled by default, and can be configured by appending the pipe character '|'\n * followed by the 'highlight-true'/'highlight-false' option, such as 'extractive|highlight-true'. Defaults to 'None'.\n */\n captions?: Captions;\n /**\n * The list of field names used for semantic search.\n */\n semanticFields?: string[];\n}\n\n/**\n * Contains a document found by a search query, plus associated metadata.\n */\nexport type SearchResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = {\n /**\n * The relevance score of the document compared to other documents returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly score: number;\n /**\n * The relevance score computed by the semantic ranker for the top search results. Search results are sorted by the RerankerScore first and then by the Score. RerankerScore is only returned for queries of type 'semantic'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly rerankerScore?: number;\n /**\n * Text fragments from the document that indicate the matching search terms, organized by each\n * applicable field; null if hit highlighting was not enabled for the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly highlights?: { [k in SelectFields<Model>]?: string[] };\n /**\n * Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly captions?: CaptionResult[];\n\n document: NarrowedModel<Model, Fields>;\n};\n\n/**\n * Response containing search results from an index.\n */\nexport interface SearchDocumentsResultBase {\n /**\n * The total count of results found by the search operation, or null if the count was not\n * requested. If present, the count may be greater than the number of results in this response.\n * This can happen if you use the $top or $skip parameters, or if Azure Cognitive Search can't\n * return all the requested documents in a single Search response.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly count?: number;\n /**\n * A value indicating the percentage of the index that was included in the query, or null if\n * minimumCoverage was not specified in the request.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly coverage?: number;\n /**\n * The facet query results for the search operation, organized as a collection of buckets for\n * each faceted field; null if the query did not include any facet expressions.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly facets?: { [propertyName: string]: FacetResult[] };\n /**\n * The answers query results for the search operation; null if the answers query parameter was\n * not specified or set to 'none'.\n * NOTE: This property will not be serialized. It can only be populated by the server.\n */\n readonly answers?: AnswerResult[];\n}\n\n/**\n * Response containing search results from an index.\n */\nexport interface SearchDocumentsResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends SearchDocumentsResultBase {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SearchIterator<Model, Fields>;\n}\n\n/**\n * Response containing search page results from an index.\n */\nexport interface SearchDocumentsPageResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> extends SearchDocumentsResultBase {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SearchResult<Model, Fields>[];\n /**\n * A token used for retrieving the next page of results when the server\n * enforces pagination.\n */\n continuationToken?: string;\n}\n\n/**\n * Parameters for filtering, sorting, fuzzy matching, and other suggestions query behaviors.\n */\nexport interface SuggestRequest<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * An OData expression that filters the documents considered for suggestions.\n */\n filter?: string;\n /**\n * A value indicating whether to use fuzzy matching for the suggestion query. Default is false.\n * When set to true, the query will find suggestions even if there's a substituted or missing\n * character in the search text. While this provides a better experience in some scenarios, it\n * comes at a performance cost as fuzzy suggestion searches are slower and consume more\n * resources.\n */\n useFuzzyMatching?: boolean;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,\n * hit highlighting of suggestions is disabled.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If\n * omitted, hit highlighting of suggestions is disabled.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by a\n * suggestion query in order for the query to be reported as a success. This parameter can be\n * useful for ensuring search availability even for services with only one replica. The default\n * is 80.\n */\n minimumCoverage?: number;\n /**\n * The list of OData $orderby expressions by which to sort the results. Each\n * expression can be either a field name or a call to either the geo.distance() or the\n * search.score() functions. Each expression can be followed by asc to indicate ascending, or\n * desc to indicate descending. The default is ascending order. Ties will be broken by the match\n * scores of documents. If no $orderby is specified, the default sort order is descending by\n * document match score. There can be at most 32 $orderby clauses.\n */\n orderBy?: string[];\n /**\n * The comma-separated list of field names to search for the specified search text. Target fields\n * must be included in the specified suggester.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The list of fields to retrieve. If unspecified, only the key field will be\n * included in the results.\n */\n select?: [string] extends [Fields] ? string[] : Fields[] | Readonly<Fields[]>;\n /**\n /**\n * The number of suggestions to retrieve. This must be a value between 1 and 100. The default is\n * 5.\n */\n top?: number;\n}\n\n/**\n * A result containing a document found by a suggestion query, plus associated metadata.\n */\nexport type SuggestResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = {\n /**\n * The text of the suggestion result.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly text: string;\n document: SuggestNarrowedModel<Model, Fields>;\n};\n\n/**\n * Response containing suggestion query results from an index.\n */\nexport interface SuggestDocumentsResult<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> {\n /**\n * The sequence of results returned by the query.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly results: SuggestResult<Model, Fields>[];\n /**\n * A value indicating the percentage of the index that was included in the query, or null if\n * minimumCoverage was not set in the request.\n * **NOTE: This property will not be serialized. It can only be populated by the server.**\n */\n readonly coverage?: number;\n}\n\n/**\n * Parameters for fuzzy matching, and other autocomplete query behaviors.\n */\nexport interface AutocompleteRequest<Model extends object> {\n /**\n * Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles\n * and 'oneTermWithContext' to use the current context while producing auto-completed terms.\n * Possible values include: 'oneTerm', 'twoTerms', 'oneTermWithContext'\n */\n autocompleteMode?: AutocompleteMode;\n /**\n * An OData expression that filters the documents used to produce completed terms for the\n * Autocomplete result.\n */\n filter?: string;\n /**\n * A value indicating whether to use fuzzy matching for the autocomplete query. Default is false.\n * When set to true, the query will autocomplete terms even if there's a substituted or missing\n * character in the search text. While this provides a better experience in some scenarios, it\n * comes at a performance cost as fuzzy autocomplete queries are slower and consume more\n * resources.\n */\n useFuzzyMatching?: boolean;\n /**\n * A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,\n * hit highlighting is disabled.\n */\n highlightPostTag?: string;\n /**\n * A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If\n * omitted, hit highlighting is disabled.\n */\n highlightPreTag?: string;\n /**\n * A number between 0 and 100 indicating the percentage of the index that must be covered by an\n * autocomplete query in order for the query to be reported as a success. This parameter can be\n * useful for ensuring search availability even for services with only one replica. The default\n * is 80.\n */\n minimumCoverage?: number;\n /**\n * The comma-separated list of field names to consider when querying for auto-completed terms.\n * Target fields must be included in the specified suggester.\n */\n searchFields?: SelectFields<Model>[] | Readonly<SelectFields<Model>[]>;\n /**\n * The number of auto-completed terms to retrieve. This must be a value between 1 and 100. The\n * default is 5.\n */\n top?: number;\n}\n\n/**\n * Represents an index action that operates on a document.\n */\nexport type IndexDocumentsAction<T> = {\n /**\n * The operation to perform on a document in an indexing batch. Possible values include:\n * 'upload', 'merge', 'mergeOrUpload', 'delete'\n */\n __actionType: IndexActionType;\n} & Partial<T>;\n\n// END manually modified generated interfaces\n\n// Utility types\n\nexport type UnionToIntersection<U> =\n // Distribute members of U into parameter position of a union of functions\n (\n U extends unknown ? (_: U) => unknown : never\n ) extends // Infer the intersection of the members of U as a single intersected parameter type\n (_: infer I) => unknown\n ? I\n : never;\n\n// Types that should not be included in SelectFields recursion\nexport type ExcludedODataTypes = Date | GeographyPoint;\n\n/**\n * Produces a union of valid Cognitive Search OData $select paths for T\n * using a post-order traversal of the field tree rooted at T.\n */\nexport type SelectFields<T extends object> = T extends Array<infer Elem>\n ? // Allow selecting fields only from elements which are objects\n Elem extends object\n ? SelectFields<Elem>\n : never\n : {\n // Only consider string keys\n [Key in keyof T]: Key extends string\n ? NonNullable<T[Key]> extends object\n ? NonNullable<T[Key]> extends ExcludedODataTypes\n ? // Excluded, so don't recur\n Key\n : SelectFields<NonNullable<T[Key]>> extends infer NextPaths\n ? // Narrow NextPaths' type for template literal\n NextPaths extends string\n ? // Union this key with all the next paths separated with '/'\n Key | `${Key}/${NextPaths}`\n : // We didn't infer any nested paths, so just use this key\n Key\n : never\n : // Not an object, so can't recur\n Key\n : never;\n }[keyof T & string] &\n // Filter out undefined properties\n string;\n\n/**\n * Deeply pick fields of T using valid Cognitive Search OData $select\n * paths.\n */\nexport type SearchPick<T extends object, Paths extends SelectFields<T>> =\n // The default behavior of a client with no model is to return an object type\n [T] extends [never]\n ? object\n : // We're going to get a union of individual interfaces for each field in T that's selected, so convert that to an intersection.\n UnionToIntersection<\n // Paths is a union or single string type, so if it's a union it will be _distributed_ over this conditional.\n // Fortunately, template literal types are not greedy, so we can infer the field name easily.\n Paths extends `${infer FieldName}/${infer RestPaths}`\n ? // Symbols and numbers are invalid types for field names\n FieldName extends keyof T & string\n ? NonNullable<T[FieldName]> extends Array<infer Elem>\n ? Elem extends object\n ? // Extends clause is necessary to refine the constraint of RestPaths\n RestPaths extends SelectFields<Elem>\n ? // Narrow the type of every element in the array\n {\n [Key in keyof T as Key & FieldName]: Array<SearchPick<Elem, RestPaths>>;\n }\n : // Unreachable by construction\n never\n : // Don't recur on arrays of non-object types\n never\n : NonNullable<T[FieldName]> extends object\n ? // Recur :)\n {\n [Key in keyof T as Key & FieldName]: RestPaths extends SelectFields<\n T[Key] & {\n // This empty intersection fixes `T[Key]` not being narrowed to an object type in older versions of TS\n }\n >\n ?\n | SearchPick<\n T[Key] & {\n // Ditto\n },\n RestPaths\n >\n | Extract<T[Key], null>\n : // Unreachable by construction\n never;\n }\n : // Unreachable by construction\n never\n : // Ignore symbols and numbers\n never\n : // Otherwise, capture the paths that are simple keys of T itself\n Pick<T, Paths> | Extract<T, null>\n > & {\n // This useless intersection actually prevents the TypeScript language server from\n // expanding the definition of SearchPick<T, Paths> in IntelliSense. Since we're\n // sure the type always yields an object, this intersection does not alter the type\n // at all, only the display string of the type.\n };\n\nexport type ExtractDocumentKey<Model> = {\n [K in keyof Model as Model[K] extends string | undefined ? K : never]: Model[K];\n};\n\nexport type NarrowedModel<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> =\n // Avoid calculating the type if every field is specified\n SelectFields<Model> extends Fields ? Model : SearchPick<Model, Fields>;\n\nexport type SuggestNarrowedModel<\n Model extends object,\n Fields extends SelectFields<Model> = SelectFields<Model>\n> = [Model] extends [never]\n ? // The client was instantiated with no model, so the narrowest possible result type is `object`\n object\n : // null represents the default case (no fields specified as selected)\n [Fields] extends [never]\n ? // Filter nullable (i.e. non-key) properties from the model, as they're not returned by the service by default\n keyof ExtractDocumentKey<Model> extends never\n ? // Return the original model if none of the properties are non-nullable\n Model\n : ExtractDocumentKey<Model>\n : // Fields isn't narrowed to exclude null by the first condition, so it needs to be narrowed here\n Fields extends SelectFields<Model>\n ? NarrowedModel<Model, Fields>\n : // Unreachable by construction\n never;\n"]}
|
|
@@ -58,6 +58,7 @@ export class SearchClient {
|
|
|
58
58
|
* non-nullable type `string`.
|
|
59
59
|
*/
|
|
60
60
|
constructor(endpoint, indexName, credential, options = {}) {
|
|
61
|
+
var _a, _b;
|
|
61
62
|
/// Maintenance note: when updating supported API versions,
|
|
62
63
|
/// the ContinuationToken logic will need to be updated below.
|
|
63
64
|
/**
|
|
@@ -94,20 +95,9 @@ export class SearchClient {
|
|
|
94
95
|
],
|
|
95
96
|
},
|
|
96
97
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
this.serviceVersion = options.apiVersion;
|
|
102
|
-
this.apiVersion = options.apiVersion;
|
|
103
|
-
}
|
|
104
|
-
if (options.serviceVersion) {
|
|
105
|
-
if (!utils.serviceVersions.includes(options.serviceVersion)) {
|
|
106
|
-
throw new Error(`Invalid Service Version: ${options.serviceVersion}`);
|
|
107
|
-
}
|
|
108
|
-
this.serviceVersion = options.serviceVersion;
|
|
109
|
-
this.apiVersion = options.serviceVersion;
|
|
110
|
-
}
|
|
98
|
+
this.serviceVersion =
|
|
99
|
+
(_b = (_a = options.serviceVersion) !== null && _a !== void 0 ? _a : options.apiVersion) !== null && _b !== void 0 ? _b : utils.defaultServiceVersion;
|
|
100
|
+
this.apiVersion = this.serviceVersion;
|
|
111
101
|
this.client = new GeneratedClient(this.endpoint, this.indexName, this.serviceVersion, internalClientPipelineOptions);
|
|
112
102
|
if (isTokenCredential(credential)) {
|
|
113
103
|
const scope = options.audience
|
|
@@ -253,21 +243,28 @@ export class SearchClient {
|
|
|
253
243
|
}
|
|
254
244
|
listSearchResultsAll(firstPage, searchText, options = {}) {
|
|
255
245
|
return __asyncGenerator(this, arguments, function* listSearchResultsAll_1() {
|
|
256
|
-
var e_1,
|
|
246
|
+
var _a, e_1, _b, _c;
|
|
257
247
|
yield __await(yield* __asyncDelegator(__asyncValues(firstPage.results)));
|
|
258
248
|
if (firstPage.continuationToken) {
|
|
259
249
|
try {
|
|
260
|
-
for (var
|
|
250
|
+
for (var _d = true, _e = __asyncValues(this.listSearchResultsPage(searchText, options, {
|
|
261
251
|
continuationToken: firstPage.continuationToken,
|
|
262
|
-
})),
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
})), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
|
|
253
|
+
_c = _f.value;
|
|
254
|
+
_d = false;
|
|
255
|
+
try {
|
|
256
|
+
const page = _c;
|
|
257
|
+
yield __await(yield* __asyncDelegator(__asyncValues(page.results)));
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
_d = true;
|
|
261
|
+
}
|
|
265
262
|
}
|
|
266
263
|
}
|
|
267
264
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
268
265
|
finally {
|
|
269
266
|
try {
|
|
270
|
-
if (
|
|
267
|
+
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
271
268
|
}
|
|
272
269
|
finally { if (e_1) throw e_1.error; }
|
|
273
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchClient.js","sourceRoot":"","sources":["../../src/searchClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,YAAY,I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Q;gBACzB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;aAC9C,CAAC;SACH;QAAC,OAAO,CAAM,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,YAAY,EAAE,CAAC,CAAC;SAC7E;IACH,CAAC;IAED,wDAAwD;IAChD,uBAAuB,CAC7B,GAAM;QAKN,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,KAAqB,GAAG,EAAnB,WAAW,UAAK,GAAG,EAArE,mDAA+D,CAAM,CAAC;QAE5E,OAAO;YACL,gBAAgB,EAAE;gBAChB,WAAW;gBACX,cAAc;gBACd,cAAc;aACf;YACD,WAAW;SACZ,CAAC;IACJ,CAAC;IAEO,aAAa,CAAqC,MAAiB;QACzE,IAAI,MAAM,EAAE;YACV,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,mBAAmB,CAAC,YAAoC;QAC9D,IAAI,YAAY,EAAE;YAChB,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/B;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,qBAAqB,CAAC,cAAyB;QACrD,IAAI,cAAc,EAAE;YAClB,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACjC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAEO,cAAc,CAAC,OAAkB;QACvC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC1B;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { SearchClient as GeneratedClient } from \"./generated/data/searchClient\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createSearchApiKeyCredentialPolicy } from \"./searchApiKeyCredentialPolicy\";\nimport { SDK_VERSION } from \"./constants\";\nimport { logger } from \"./logger\";\nimport {\n AutocompleteRequest,\n AutocompleteResult,\n IndexDocumentsResult,\n SuggestRequest,\n} from \"./generated/data/models\";\nimport { createSpan } from \"./tracing\";\nimport { deserialize, serialize } from \"./serialization\";\nimport {\n AutocompleteOptions,\n CountDocumentsOptions,\n DeleteDocumentsOptions,\n GetDocumentOptions,\n IndexDocumentsOptions,\n ListSearchResultsPageSettings,\n MergeDocumentsOptions,\n MergeOrUploadDocumentsOptions,\n SearchDocumentsPageResult,\n SearchDocumentsResult,\n SearchIterator,\n SearchOptions,\n SearchRequest,\n SelectFields,\n SearchResult,\n SuggestDocumentsResult,\n SuggestOptions,\n UploadDocumentsOptions,\n NarrowedModel,\n} from \"./indexModels\";\nimport { createOdataMetadataPolicy } from \"./odataMetadataPolicy\";\nimport { IndexDocumentsBatch } from \"./indexDocumentsBatch\";\nimport { decode, encode } from \"./base64\";\nimport * as utils from \"./serviceUtils\";\nimport { IndexDocumentsClient } from \"./searchIndexingBufferedSender\";\nimport { ExtendedCommonClientOptions } from \"@azure/core-http-compat\";\nimport { KnownSearchAudience } from \"./searchAudience\";\n\n/**\n * Client options used to configure Cognitive Search API requests.\n */\nexport interface SearchClientOptions extends ExtendedCommonClientOptions {\n /**\n * The API version to use when communicating with the service.\n * @deprecated use {@link serviceVersion} instead\n */\n apiVersion?: string;\n\n /**\n * The service version to use when communicating with the service.\n */\n serviceVersion?: string;\n\n /**\n * The Audience to use for authentication with Azure Active Directory (AAD). The\n * audience is not considered when using a shared key.\n * {@link KnownSearchAudience} can be used interchangeably with audience\n */\n audience?: string;\n}\n\n/**\n * Class used to perform operations against a search index,\n * including querying documents in the index as well as\n * adding, updating, and removing them.\n */\nexport class SearchClient<Model extends object> implements IndexDocumentsClient<Model> {\n /// Maintenance note: when updating supported API versions,\n /// the ContinuationToken logic will need to be updated below.\n\n /**\n * The service version to use when communicating with the service.\n */\n public readonly serviceVersion: string = utils.defaultServiceVersion;\n\n /**\n * The API version to use when communicating with the service.\n * @deprecated use {@Link serviceVersion} instead\n */\n public readonly apiVersion: string = utils.defaultServiceVersion;\n\n /**\n * The endpoint of the search service\n */\n public readonly endpoint: string;\n\n /**\n * The name of the index\n */\n public readonly indexName: string;\n\n /**\n * @internal\n * @hidden\n * A reference to the auto-generated SearchClient\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of SearchClient.\n *\n * Example usage:\n * ```ts\n * const { SearchClient, AzureKeyCredential } = require(\"@azure/search-documents\");\n *\n * const client = new SearchClient(\n * \"<endpoint>\",\n * \"<indexName>\",\n * new AzureKeyCredential(\"<Admin Key>\")\n * );\n * ```\n *\n * Optionally, the type of the model can be used to enable strong typing and type hints:\n * ```ts\n * type Model = {\n * keyName: string;\n * field1?: string | null;\n * field2?: { anotherField?: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * ...\n * );\n * ```\n *\n * @param endpoint - The endpoint of the search service\n * @param indexName - The name of the index\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Search client.\n *\n * @typeParam Model - An optional type that represents the documents stored in\n * the search index. For the best typing experience, all non-key fields should\n * be marked optional and nullable, and the key property should have the\n * non-nullable type `string`.\n */\n constructor(\n endpoint: string,\n indexName: string,\n credential: KeyCredential | TokenCredential,\n options: SearchClientOptions = {}\n ) {\n this.endpoint = endpoint;\n this.indexName = indexName;\n\n const libInfo = `azsdk-js-search-documents/${SDK_VERSION}`;\n if (!options.userAgentOptions) {\n options.userAgentOptions = {};\n }\n if (options.userAgentOptions.userAgentPrefix) {\n options.userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;\n } else {\n options.userAgentOptions.userAgentPrefix = libInfo;\n }\n\n const internalClientPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\n \"elapsed-time\",\n \"Location\",\n \"OData-MaxVersion\",\n \"OData-Version\",\n \"Prefer\",\n \"throttle-reason\",\n ],\n },\n },\n };\n\n if (options.apiVersion) {\n if (!utils.serviceVersions.includes(options.apiVersion)) {\n throw new Error(`Invalid Api Version: ${options.apiVersion}`);\n }\n this.serviceVersion = options.apiVersion;\n this.apiVersion = options.apiVersion;\n }\n\n if (options.serviceVersion) {\n if (!utils.serviceVersions.includes(options.serviceVersion)) {\n throw new Error(`Invalid Service Version: ${options.serviceVersion}`);\n }\n this.serviceVersion = options.serviceVersion;\n this.apiVersion = options.serviceVersion;\n }\n\n this.client = new GeneratedClient(\n this.endpoint,\n this.indexName,\n this.serviceVersion,\n internalClientPipelineOptions\n );\n\n if (isTokenCredential(credential)) {\n const scope: string = options.audience\n ? `${options.audience}/.default`\n : `${KnownSearchAudience.AzurePublicCloud}/.default`;\n\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({ credential, scopes: scope })\n );\n } else {\n this.client.pipeline.addPolicy(createSearchApiKeyCredentialPolicy(credential));\n }\n\n this.client.pipeline.addPolicy(createOdataMetadataPolicy(\"none\"));\n }\n\n /**\n * Retrieves the number of documents in the index.\n * @param options - Options to the count operation.\n */\n public async getDocumentsCount(options: CountDocumentsOptions = {}): Promise<number> {\n const { span, updatedOptions } = createSpan(\"SearchClient-getDocumentsCount\", options);\n try {\n let documentsCount: number = 0;\n await this.client.documents.count({\n ...updatedOptions,\n onResponse: (rawResponse, flatResponse) => {\n documentsCount = Number(rawResponse.bodyAsText);\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n },\n });\n\n return documentsCount;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Based on a partial searchText from the user, return a list\n * of potential completion strings based on a specified suggester.\n * @param searchText - The search text on which to base autocomplete results.\n * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.\n * @param options - Options to the autocomplete operation.\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const autocompleteResult = await client.autocomplete(\n * \"searchText\",\n * \"suggesterName\",\n * { searchFields }\n * );\n * ```\n */\n public async autocomplete(\n searchText: string,\n suggesterName: string,\n options: AutocompleteOptions<Model> = {}\n ): Promise<AutocompleteResult> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { searchFields, ...nonFieldOptions } = restOptions;\n const fullOptions: AutocompleteRequest = {\n searchText: searchText,\n suggesterName: suggesterName,\n searchFields: this.convertSearchFields(searchFields),\n ...nonFieldOptions,\n };\n\n if (!fullOptions.searchText) {\n throw new RangeError(\"searchText must be provided.\");\n }\n\n if (!fullOptions.suggesterName) {\n throw new RangeError(\"suggesterName must be provided.\");\n }\n\n const { span, updatedOptions } = createSpan(\"SearchClient-autocomplete\", operationOptions);\n\n try {\n const result = await this.client.documents.autocompletePost(fullOptions, updatedOptions);\n return result;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async searchDocuments<Fields extends SelectFields<Model>>(\n searchText?: string,\n options: SearchOptions<Model, Fields> = {},\n nextPageParameters: SearchRequest = {}\n ): Promise<SearchDocumentsPageResult<Model, Fields>> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { select, searchFields, orderBy, semanticFields, ...nonFieldOptions } = restOptions;\n const fullOptions: SearchRequest = {\n searchFields: this.convertSearchFields(searchFields),\n semanticFields: this.convertSemanticFields(semanticFields),\n select: this.convertSelect<Fields>(select) || \"*\",\n orderBy: this.convertOrderBy(orderBy),\n ...nonFieldOptions,\n ...nextPageParameters,\n };\n\n const { span, updatedOptions } = createSpan(\"SearchClient-searchDocuments\", operationOptions);\n\n try {\n const result = await this.client.documents.searchPost(\n {\n ...fullOptions,\n includeTotalResultCount: fullOptions.includeTotalCount,\n searchText: searchText,\n },\n updatedOptions\n );\n\n const { results, count, coverage, facets, answers, nextLink } = result;\n\n const modifiedResults = utils.generatedSearchResultToPublicSearchResult<Model, Fields>(\n results\n );\n\n const converted: SearchDocumentsPageResult<Model, Fields> = {\n results: modifiedResults,\n count,\n coverage,\n facets,\n answers,\n continuationToken: this.encodeContinuationToken(nextLink, result.nextPageParameters),\n };\n\n return deserialize<SearchDocumentsPageResult<Model, Fields>>(converted);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async *listSearchResultsPage<Fields extends SelectFields<Model>>(\n searchText?: string,\n options: SearchOptions<Model, Fields> = {},\n settings: ListSearchResultsPageSettings = {}\n ): AsyncIterableIterator<SearchDocumentsPageResult<Model, Fields>> {\n let decodedContinuation = this.decodeContinuationToken(settings.continuationToken);\n let result = await this.searchDocuments(\n searchText,\n options,\n decodedContinuation?.nextPageParameters\n );\n\n yield result;\n\n // Technically, we should also leverage nextLink, but the generated code\n // doesn't support this yet.\n while (result.continuationToken) {\n decodedContinuation = this.decodeContinuationToken(result.continuationToken);\n result = await this.searchDocuments(\n searchText,\n options,\n decodedContinuation?.nextPageParameters\n );\n yield result;\n }\n }\n\n private async *listSearchResultsAll<Fields extends SelectFields<Model>>(\n firstPage: SearchDocumentsPageResult<Model, Fields>,\n searchText?: string,\n options: SearchOptions<Model, Fields> = {}\n ): AsyncIterableIterator<SearchResult<Model, Fields>> {\n yield* firstPage.results;\n if (firstPage.continuationToken) {\n for await (const page of this.listSearchResultsPage(searchText, options, {\n continuationToken: firstPage.continuationToken,\n })) {\n yield* page.results;\n }\n }\n }\n\n private listSearchResults<Fields extends SelectFields<Model>>(\n firstPage: SearchDocumentsPageResult<Model, Fields>,\n searchText?: string,\n options: SearchOptions<Model, Fields> = {}\n ): SearchIterator<Model, Fields> {\n const iter = this.listSearchResultsAll(firstPage, searchText, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: ListSearchResultsPageSettings = {}) => {\n return this.listSearchResultsPage(searchText, options, settings);\n },\n };\n }\n\n /**\n * Performs a search on the current index given\n * the specified arguments.\n * @param searchText - Text to search\n * @param options - Options for the search operation.\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const select = [\"azure/sdk\"] as const;\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const searchResult = await client.search(\"searchText\", {\n * select,\n * searchFields,\n * });\n * ```\n */\n public async search<Fields extends SelectFields<Model>>(\n searchText?: string,\n options?: SearchOptions<Model, Fields>\n ): Promise<SearchDocumentsResult<Model, Fields>> {\n const { span, updatedOptions } = createSpan(\"SearchClient-search\", options);\n\n try {\n const pageResult = await this.searchDocuments(searchText, updatedOptions);\n\n const { count, coverage, facets, answers } = pageResult;\n\n return {\n count,\n coverage,\n facets,\n answers,\n results: this.listSearchResults(pageResult, searchText, updatedOptions),\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Returns a short list of suggestions based on the searchText\n * and specified suggester.\n * @param searchText - The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.\n * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.\n * @param options - Options for the suggest operation\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const select = [\"azure/sdk\"] as const;\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const suggestResult = await client.suggest(\"searchText\", \"suggesterName\", {\n * select,\n * searchFields,\n * });\n * ```\n */\n public async suggest<Fields extends SelectFields<Model> = never>(\n searchText: string,\n suggesterName: string,\n options: SuggestOptions<Model, Fields> = {}\n ): Promise<SuggestDocumentsResult<Model, Fields>> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { select, searchFields, orderBy, ...nonFieldOptions } = restOptions;\n const fullOptions: SuggestRequest = {\n searchText: searchText,\n suggesterName: suggesterName,\n searchFields: this.convertSearchFields(searchFields),\n select: this.convertSelect<Fields>(select),\n orderBy: this.convertOrderBy(orderBy),\n ...nonFieldOptions,\n };\n\n if (!fullOptions.searchText) {\n throw new RangeError(\"searchText must be provided.\");\n }\n\n if (!fullOptions.suggesterName) {\n throw new RangeError(\"suggesterName must be provided.\");\n }\n\n const { span, updatedOptions } = createSpan(\"SearchClient-suggest\", operationOptions);\n\n try {\n const result = await this.client.documents.suggestPost(fullOptions, updatedOptions);\n\n const modifiedResult = utils.generatedSuggestDocumentsResultToPublicSuggestDocumentsResult<\n Model,\n Fields\n >(result);\n\n return deserialize<SuggestDocumentsResult<Model, Fields>>(modifiedResult);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Retrieve a particular document from the index by key.\n * @param key - The primary key value of the document\n * @param options - Additional options\n */\n public async getDocument<Fields extends SelectFields<Model>>(\n key: string,\n options: GetDocumentOptions<Model, Fields> = {}\n ): Promise<NarrowedModel<Model, Fields>> {\n const { span, updatedOptions } = createSpan(\"SearchClient-getDocument\", options);\n try {\n const result = await this.client.documents.get(key, {\n ...updatedOptions,\n selectedFields: updatedOptions.selectedFields as string[],\n });\n return deserialize<NarrowedModel<Model, Fields>>(result);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Perform a set of index modifications (upload, merge, mergeOrUpload, delete)\n * for the given set of documents.\n * This operation may partially succeed and not all document operations will\n * be reflected in the index. If you would like to treat this as an exception,\n * set the `throwOnAnyFailure` option to true.\n * For more details about how merging works, see: https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param batch - An array of actions to perform on the index.\n * @param options - Additional options.\n */\n public async indexDocuments(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n batch: IndexDocumentsBatch<Model>,\n options: IndexDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-indexDocuments\", options);\n try {\n let status: number = 0;\n const result = await this.client.documents.index(\n { actions: serialize(batch.actions) },\n {\n ...updatedOptions,\n onResponse: (rawResponse, flatResponse) => {\n status = rawResponse.status;\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n },\n }\n );\n if (options.throwOnAnyFailure && status === 207) {\n throw result;\n }\n return result;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Upload an array of documents to the index.\n * @param documents - The documents to upload.\n * @param options - Additional options.\n */\n public async uploadDocuments(\n documents: Model[],\n options: UploadDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-uploadDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.upload(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update a set of documents in the index.\n * For more details about how merging works, see https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param documents - The updated documents.\n * @param options - Additional options.\n */\n public async mergeDocuments(\n documents: Model[],\n options: MergeDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-mergeDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.merge(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update a set of documents in the index or upload them if they don't exist.\n * For more details about how merging works, see https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param documents - The updated documents.\n * @param options - Additional options.\n */\n public async mergeOrUploadDocuments(\n documents: Model[],\n options: MergeOrUploadDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-mergeDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.mergeOrUpload(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Delete a set of documents.\n * @param documents - Documents to be deleted.\n * @param options - Additional options.\n */\n public async deleteDocuments(\n documents: Model[],\n options?: DeleteDocumentsOptions\n ): Promise<IndexDocumentsResult>;\n\n /**\n * Delete a set of documents.\n * @param keyName - The name of their primary key in the index.\n * @param keyValues - The primary key values of documents to delete.\n * @param options - Additional options.\n */\n public async deleteDocuments(\n keyName: keyof Model,\n keyValues: string[],\n options?: DeleteDocumentsOptions\n ): Promise<IndexDocumentsResult>;\n\n public async deleteDocuments(\n keyNameOrDocuments: keyof Model | Model[],\n keyValuesOrOptions?: string[] | DeleteDocumentsOptions,\n options: DeleteDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-deleteDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n if (typeof keyNameOrDocuments === \"string\") {\n batch.delete(keyNameOrDocuments, keyValuesOrOptions as string[]);\n } else {\n batch.delete(keyNameOrDocuments as Model[]);\n }\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private encodeContinuationToken(\n nextLink: string | undefined,\n nextPageParameters: SearchRequest | undefined\n ): string | undefined {\n if (!nextLink || !nextPageParameters) {\n return undefined;\n }\n const payload = JSON.stringify({\n apiVersion: this.apiVersion,\n nextLink,\n nextPageParameters,\n });\n return encode(payload);\n }\n\n private decodeContinuationToken(\n token?: string\n ): { nextPageParameters: SearchRequest; nextLink: string } | undefined {\n if (!token) {\n return undefined;\n }\n\n const decodedToken = decode(token);\n\n try {\n const result: {\n apiVersion: string;\n nextLink: string;\n nextPageParameters: SearchRequest;\n } = JSON.parse(decodedToken);\n\n if (result.apiVersion !== this.apiVersion) {\n throw new RangeError(`Continuation token uses unsupported apiVersion \"${this.apiVersion}\"`);\n }\n\n return {\n nextLink: result.nextLink,\n nextPageParameters: result.nextPageParameters,\n };\n } catch (e: any) {\n throw new Error(`Corrupted or invalid continuation token: ${decodedToken}`);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n private extractOperationOptions<T extends OperationOptions>(\n obj: T\n ): {\n operationOptions: OperationOptions;\n restOptions: any;\n } {\n const { abortSignal, requestOptions, tracingOptions, ...restOptions } = obj;\n\n return {\n operationOptions: {\n abortSignal,\n requestOptions,\n tracingOptions,\n },\n restOptions,\n };\n }\n\n private convertSelect<Fields extends SelectFields<Model>>(select?: Fields[]): string | undefined {\n if (select) {\n return select.join(\",\");\n }\n return select;\n }\n\n private convertSearchFields(searchFields?: SelectFields<Model>[]): string | undefined {\n if (searchFields) {\n return searchFields.join(\",\");\n }\n return searchFields;\n }\n\n private convertSemanticFields(semanticFields?: string[]): string | undefined {\n if (semanticFields) {\n return semanticFields.join(\",\");\n }\n return semanticFields;\n }\n\n private convertOrderBy(orderBy?: string[]): string | undefined {\n if (orderBy) {\n return orderBy.join(\",\");\n }\n return orderBy;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"searchClient.js","sourceRoot":"","sources":["../../src/searchClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsBzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAyBvD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAgCvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,YACE,QAAgB,EAChB,SAAiB,EACjB,UAA2C,EAC3C,U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;gBACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;aAC9C,CAAC;SACH;QAAC,OAAO,CAAM,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,YAAY,EAAE,CAAC,CAAC;SAC7E;IACH,CAAC;IAED,wDAAwD;IAChD,uBAAuB,CAC7B,GAAM;QAKN,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,KAAqB,GAAG,EAAnB,WAAW,UAAK,GAAG,EAArE,mDAA+D,CAAM,CAAC;QAE5E,OAAO;YACL,gBAAgB,EAAE;gBAChB,WAAW;gBACX,cAAc;gBACd,cAAc;aACf;YACD,WAAW;SACZ,CAAC;IACJ,CAAC;IAEO,aAAa,CAAqC,MAAiB;QACzE,IAAI,MAAM,EAAE;YACV,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,mBAAmB,CAAC,YAAoC;QAC9D,IAAI,YAAY,EAAE;YAChB,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC/B;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,qBAAqB,CAAC,cAAyB;QACrD,IAAI,cAAc,EAAE;YAClB,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACjC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAEO,cAAc,CAAC,OAAkB;QACvC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC1B;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { SearchClient as GeneratedClient } from \"./generated/data/searchClient\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createSearchApiKeyCredentialPolicy } from \"./searchApiKeyCredentialPolicy\";\nimport { SDK_VERSION } from \"./constants\";\nimport { logger } from \"./logger\";\nimport {\n AutocompleteRequest,\n AutocompleteResult,\n IndexDocumentsResult,\n SuggestRequest,\n} from \"./generated/data/models\";\nimport { createSpan } from \"./tracing\";\nimport { deserialize, serialize } from \"./serialization\";\nimport {\n AutocompleteOptions,\n CountDocumentsOptions,\n DeleteDocumentsOptions,\n GetDocumentOptions,\n IndexDocumentsOptions,\n ListSearchResultsPageSettings,\n MergeDocumentsOptions,\n MergeOrUploadDocumentsOptions,\n SearchDocumentsPageResult,\n SearchDocumentsResult,\n SearchIterator,\n SearchOptions,\n SearchRequest,\n SelectFields,\n SearchResult,\n SuggestDocumentsResult,\n SuggestOptions,\n UploadDocumentsOptions,\n NarrowedModel,\n} from \"./indexModels\";\nimport { createOdataMetadataPolicy } from \"./odataMetadataPolicy\";\nimport { IndexDocumentsBatch } from \"./indexDocumentsBatch\";\nimport { decode, encode } from \"./base64\";\nimport * as utils from \"./serviceUtils\";\nimport { IndexDocumentsClient } from \"./searchIndexingBufferedSender\";\nimport { ExtendedCommonClientOptions } from \"@azure/core-http-compat\";\nimport { KnownSearchAudience } from \"./searchAudience\";\n\n/**\n * Client options used to configure Cognitive Search API requests.\n */\nexport interface SearchClientOptions extends ExtendedCommonClientOptions {\n /**\n * The API version to use when communicating with the service.\n * @deprecated use {@link serviceVersion} instead\n */\n apiVersion?: string;\n\n /**\n * The service version to use when communicating with the service.\n */\n serviceVersion?: string;\n\n /**\n * The Audience to use for authentication with Azure Active Directory (AAD). The\n * audience is not considered when using a shared key.\n * {@link KnownSearchAudience} can be used interchangeably with audience\n */\n audience?: string;\n}\n\n/**\n * Class used to perform operations against a search index,\n * including querying documents in the index as well as\n * adding, updating, and removing them.\n */\nexport class SearchClient<Model extends object> implements IndexDocumentsClient<Model> {\n /// Maintenance note: when updating supported API versions,\n /// the ContinuationToken logic will need to be updated below.\n\n /**\n * The service version to use when communicating with the service.\n */\n public readonly serviceVersion: string = utils.defaultServiceVersion;\n\n /**\n * The API version to use when communicating with the service.\n * @deprecated use {@Link serviceVersion} instead\n */\n public readonly apiVersion: string = utils.defaultServiceVersion;\n\n /**\n * The endpoint of the search service\n */\n public readonly endpoint: string;\n\n /**\n * The name of the index\n */\n public readonly indexName: string;\n\n /**\n * @internal\n * @hidden\n * A reference to the auto-generated SearchClient\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of SearchClient.\n *\n * Example usage:\n * ```ts\n * const { SearchClient, AzureKeyCredential } = require(\"@azure/search-documents\");\n *\n * const client = new SearchClient(\n * \"<endpoint>\",\n * \"<indexName>\",\n * new AzureKeyCredential(\"<Admin Key>\")\n * );\n * ```\n *\n * Optionally, the type of the model can be used to enable strong typing and type hints:\n * ```ts\n * type Model = {\n * keyName: string;\n * field1?: string | null;\n * field2?: { anotherField?: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * ...\n * );\n * ```\n *\n * @param endpoint - The endpoint of the search service\n * @param indexName - The name of the index\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Search client.\n *\n * @typeParam Model - An optional type that represents the documents stored in\n * the search index. For the best typing experience, all non-key fields should\n * be marked optional and nullable, and the key property should have the\n * non-nullable type `string`.\n */\n constructor(\n endpoint: string,\n indexName: string,\n credential: KeyCredential | TokenCredential,\n options: SearchClientOptions = {}\n ) {\n this.endpoint = endpoint;\n this.indexName = indexName;\n\n const libInfo = `azsdk-js-search-documents/${SDK_VERSION}`;\n if (!options.userAgentOptions) {\n options.userAgentOptions = {};\n }\n if (options.userAgentOptions.userAgentPrefix) {\n options.userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;\n } else {\n options.userAgentOptions.userAgentPrefix = libInfo;\n }\n\n const internalClientPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\n \"elapsed-time\",\n \"Location\",\n \"OData-MaxVersion\",\n \"OData-Version\",\n \"Prefer\",\n \"throttle-reason\",\n ],\n },\n },\n };\n\n this.serviceVersion =\n options.serviceVersion ?? options.apiVersion ?? utils.defaultServiceVersion;\n this.apiVersion = this.serviceVersion;\n\n this.client = new GeneratedClient(\n this.endpoint,\n this.indexName,\n this.serviceVersion,\n internalClientPipelineOptions\n );\n\n if (isTokenCredential(credential)) {\n const scope: string = options.audience\n ? `${options.audience}/.default`\n : `${KnownSearchAudience.AzurePublicCloud}/.default`;\n\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({ credential, scopes: scope })\n );\n } else {\n this.client.pipeline.addPolicy(createSearchApiKeyCredentialPolicy(credential));\n }\n\n this.client.pipeline.addPolicy(createOdataMetadataPolicy(\"none\"));\n }\n\n /**\n * Retrieves the number of documents in the index.\n * @param options - Options to the count operation.\n */\n public async getDocumentsCount(options: CountDocumentsOptions = {}): Promise<number> {\n const { span, updatedOptions } = createSpan(\"SearchClient-getDocumentsCount\", options);\n try {\n let documentsCount: number = 0;\n await this.client.documents.count({\n ...updatedOptions,\n onResponse: (rawResponse, flatResponse) => {\n documentsCount = Number(rawResponse.bodyAsText);\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n },\n });\n\n return documentsCount;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Based on a partial searchText from the user, return a list\n * of potential completion strings based on a specified suggester.\n * @param searchText - The search text on which to base autocomplete results.\n * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.\n * @param options - Options to the autocomplete operation.\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const autocompleteResult = await client.autocomplete(\n * \"searchText\",\n * \"suggesterName\",\n * { searchFields }\n * );\n * ```\n */\n public async autocomplete(\n searchText: string,\n suggesterName: string,\n options: AutocompleteOptions<Model> = {}\n ): Promise<AutocompleteResult> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { searchFields, ...nonFieldOptions } = restOptions;\n const fullOptions: AutocompleteRequest = {\n searchText: searchText,\n suggesterName: suggesterName,\n searchFields: this.convertSearchFields(searchFields),\n ...nonFieldOptions,\n };\n\n if (!fullOptions.searchText) {\n throw new RangeError(\"searchText must be provided.\");\n }\n\n if (!fullOptions.suggesterName) {\n throw new RangeError(\"suggesterName must be provided.\");\n }\n\n const { span, updatedOptions } = createSpan(\"SearchClient-autocomplete\", operationOptions);\n\n try {\n const result = await this.client.documents.autocompletePost(fullOptions, updatedOptions);\n return result;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async searchDocuments<Fields extends SelectFields<Model>>(\n searchText?: string,\n options: SearchOptions<Model, Fields> = {},\n nextPageParameters: SearchRequest = {}\n ): Promise<SearchDocumentsPageResult<Model, Fields>> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { select, searchFields, orderBy, semanticFields, ...nonFieldOptions } = restOptions;\n const fullOptions: SearchRequest = {\n searchFields: this.convertSearchFields(searchFields),\n semanticFields: this.convertSemanticFields(semanticFields),\n select: this.convertSelect<Fields>(select) || \"*\",\n orderBy: this.convertOrderBy(orderBy),\n ...nonFieldOptions,\n ...nextPageParameters,\n };\n\n const { span, updatedOptions } = createSpan(\"SearchClient-searchDocuments\", operationOptions);\n\n try {\n const result = await this.client.documents.searchPost(\n {\n ...fullOptions,\n includeTotalResultCount: fullOptions.includeTotalCount,\n searchText: searchText,\n },\n updatedOptions\n );\n\n const { results, count, coverage, facets, answers, nextLink } = result;\n\n const modifiedResults = utils.generatedSearchResultToPublicSearchResult<Model, Fields>(\n results\n );\n\n const converted: SearchDocumentsPageResult<Model, Fields> = {\n results: modifiedResults,\n count,\n coverage,\n facets,\n answers,\n continuationToken: this.encodeContinuationToken(nextLink, result.nextPageParameters),\n };\n\n return deserialize<SearchDocumentsPageResult<Model, Fields>>(converted);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async *listSearchResultsPage<Fields extends SelectFields<Model>>(\n searchText?: string,\n options: SearchOptions<Model, Fields> = {},\n settings: ListSearchResultsPageSettings = {}\n ): AsyncIterableIterator<SearchDocumentsPageResult<Model, Fields>> {\n let decodedContinuation = this.decodeContinuationToken(settings.continuationToken);\n let result = await this.searchDocuments(\n searchText,\n options,\n decodedContinuation?.nextPageParameters\n );\n\n yield result;\n\n // Technically, we should also leverage nextLink, but the generated code\n // doesn't support this yet.\n while (result.continuationToken) {\n decodedContinuation = this.decodeContinuationToken(result.continuationToken);\n result = await this.searchDocuments(\n searchText,\n options,\n decodedContinuation?.nextPageParameters\n );\n yield result;\n }\n }\n\n private async *listSearchResultsAll<Fields extends SelectFields<Model>>(\n firstPage: SearchDocumentsPageResult<Model, Fields>,\n searchText?: string,\n options: SearchOptions<Model, Fields> = {}\n ): AsyncIterableIterator<SearchResult<Model, Fields>> {\n yield* firstPage.results;\n if (firstPage.continuationToken) {\n for await (const page of this.listSearchResultsPage(searchText, options, {\n continuationToken: firstPage.continuationToken,\n })) {\n yield* page.results;\n }\n }\n }\n\n private listSearchResults<Fields extends SelectFields<Model>>(\n firstPage: SearchDocumentsPageResult<Model, Fields>,\n searchText?: string,\n options: SearchOptions<Model, Fields> = {}\n ): SearchIterator<Model, Fields> {\n const iter = this.listSearchResultsAll(firstPage, searchText, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: ListSearchResultsPageSettings = {}) => {\n return this.listSearchResultsPage(searchText, options, settings);\n },\n };\n }\n\n /**\n * Performs a search on the current index given\n * the specified arguments.\n * @param searchText - Text to search\n * @param options - Options for the search operation.\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const select = [\"azure/sdk\"] as const;\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const searchResult = await client.search(\"searchText\", {\n * select,\n * searchFields,\n * });\n * ```\n */\n public async search<Fields extends SelectFields<Model>>(\n searchText?: string,\n options?: SearchOptions<Model, Fields>\n ): Promise<SearchDocumentsResult<Model, Fields>> {\n const { span, updatedOptions } = createSpan(\"SearchClient-search\", options);\n\n try {\n const pageResult = await this.searchDocuments(searchText, updatedOptions);\n\n const { count, coverage, facets, answers } = pageResult;\n\n return {\n count,\n coverage,\n facets,\n answers,\n results: this.listSearchResults(pageResult, searchText, updatedOptions),\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Returns a short list of suggestions based on the searchText\n * and specified suggester.\n * @param searchText - The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.\n * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.\n * @param options - Options for the suggest operation\n * @example\n * ```ts\n * import {\n * AzureKeyCredential,\n * SearchClient,\n * SelectFields,\n * } from \"@azure/search-documents\";\n *\n * type Model = {\n * key: string;\n * azure?: { sdk: string | null } | null;\n * };\n *\n * const client = new SearchClient<Model>(\n * \"endpoint.azure\",\n * \"indexName\",\n * new AzureKeyCredential(\"key\")\n * );\n *\n * const select = [\"azure/sdk\"] as const;\n * const searchFields: SelectFields<Model>[] = [\"azure/sdk\"];\n *\n * const suggestResult = await client.suggest(\"searchText\", \"suggesterName\", {\n * select,\n * searchFields,\n * });\n * ```\n */\n public async suggest<Fields extends SelectFields<Model> = never>(\n searchText: string,\n suggesterName: string,\n options: SuggestOptions<Model, Fields> = {}\n ): Promise<SuggestDocumentsResult<Model, Fields>> {\n const { operationOptions, restOptions } = this.extractOperationOptions({ ...options });\n const { select, searchFields, orderBy, ...nonFieldOptions } = restOptions;\n const fullOptions: SuggestRequest = {\n searchText: searchText,\n suggesterName: suggesterName,\n searchFields: this.convertSearchFields(searchFields),\n select: this.convertSelect<Fields>(select),\n orderBy: this.convertOrderBy(orderBy),\n ...nonFieldOptions,\n };\n\n if (!fullOptions.searchText) {\n throw new RangeError(\"searchText must be provided.\");\n }\n\n if (!fullOptions.suggesterName) {\n throw new RangeError(\"suggesterName must be provided.\");\n }\n\n const { span, updatedOptions } = createSpan(\"SearchClient-suggest\", operationOptions);\n\n try {\n const result = await this.client.documents.suggestPost(fullOptions, updatedOptions);\n\n const modifiedResult = utils.generatedSuggestDocumentsResultToPublicSuggestDocumentsResult<\n Model,\n Fields\n >(result);\n\n return deserialize<SuggestDocumentsResult<Model, Fields>>(modifiedResult);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Retrieve a particular document from the index by key.\n * @param key - The primary key value of the document\n * @param options - Additional options\n */\n public async getDocument<Fields extends SelectFields<Model>>(\n key: string,\n options: GetDocumentOptions<Model, Fields> = {}\n ): Promise<NarrowedModel<Model, Fields>> {\n const { span, updatedOptions } = createSpan(\"SearchClient-getDocument\", options);\n try {\n const result = await this.client.documents.get(key, {\n ...updatedOptions,\n selectedFields: updatedOptions.selectedFields as string[],\n });\n return deserialize<NarrowedModel<Model, Fields>>(result);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Perform a set of index modifications (upload, merge, mergeOrUpload, delete)\n * for the given set of documents.\n * This operation may partially succeed and not all document operations will\n * be reflected in the index. If you would like to treat this as an exception,\n * set the `throwOnAnyFailure` option to true.\n * For more details about how merging works, see: https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param batch - An array of actions to perform on the index.\n * @param options - Additional options.\n */\n public async indexDocuments(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n batch: IndexDocumentsBatch<Model>,\n options: IndexDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-indexDocuments\", options);\n try {\n let status: number = 0;\n const result = await this.client.documents.index(\n { actions: serialize(batch.actions) },\n {\n ...updatedOptions,\n onResponse: (rawResponse, flatResponse) => {\n status = rawResponse.status;\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n },\n }\n );\n if (options.throwOnAnyFailure && status === 207) {\n throw result;\n }\n return result;\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Upload an array of documents to the index.\n * @param documents - The documents to upload.\n * @param options - Additional options.\n */\n public async uploadDocuments(\n documents: Model[],\n options: UploadDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-uploadDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.upload(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update a set of documents in the index.\n * For more details about how merging works, see https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param documents - The updated documents.\n * @param options - Additional options.\n */\n public async mergeDocuments(\n documents: Model[],\n options: MergeDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-mergeDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.merge(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update a set of documents in the index or upload them if they don't exist.\n * For more details about how merging works, see https://docs.microsoft.com/en-us/rest/api/searchservice/AddUpdate-or-Delete-Documents\n * @param documents - The updated documents.\n * @param options - Additional options.\n */\n public async mergeOrUploadDocuments(\n documents: Model[],\n options: MergeOrUploadDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-mergeDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n batch.mergeOrUpload(documents);\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Delete a set of documents.\n * @param documents - Documents to be deleted.\n * @param options - Additional options.\n */\n public async deleteDocuments(\n documents: Model[],\n options?: DeleteDocumentsOptions\n ): Promise<IndexDocumentsResult>;\n\n /**\n * Delete a set of documents.\n * @param keyName - The name of their primary key in the index.\n * @param keyValues - The primary key values of documents to delete.\n * @param options - Additional options.\n */\n public async deleteDocuments(\n keyName: keyof Model,\n keyValues: string[],\n options?: DeleteDocumentsOptions\n ): Promise<IndexDocumentsResult>;\n\n public async deleteDocuments(\n keyNameOrDocuments: keyof Model | Model[],\n keyValuesOrOptions?: string[] | DeleteDocumentsOptions,\n options: DeleteDocumentsOptions = {}\n ): Promise<IndexDocumentsResult> {\n const { span, updatedOptions } = createSpan(\"SearchClient-deleteDocuments\", options);\n\n const batch = new IndexDocumentsBatch<Model>();\n if (typeof keyNameOrDocuments === \"string\") {\n batch.delete(keyNameOrDocuments, keyValuesOrOptions as string[]);\n } else {\n batch.delete(keyNameOrDocuments as Model[]);\n }\n\n try {\n return await this.indexDocuments(batch, updatedOptions);\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private encodeContinuationToken(\n nextLink: string | undefined,\n nextPageParameters: SearchRequest | undefined\n ): string | undefined {\n if (!nextLink || !nextPageParameters) {\n return undefined;\n }\n const payload = JSON.stringify({\n apiVersion: this.apiVersion,\n nextLink,\n nextPageParameters,\n });\n return encode(payload);\n }\n\n private decodeContinuationToken(\n token?: string\n ): { nextPageParameters: SearchRequest; nextLink: string } | undefined {\n if (!token) {\n return undefined;\n }\n\n const decodedToken = decode(token);\n\n try {\n const result: {\n apiVersion: string;\n nextLink: string;\n nextPageParameters: SearchRequest;\n } = JSON.parse(decodedToken);\n\n if (result.apiVersion !== this.apiVersion) {\n throw new RangeError(`Continuation token uses unsupported apiVersion \"${this.apiVersion}\"`);\n }\n\n return {\n nextLink: result.nextLink,\n nextPageParameters: result.nextPageParameters,\n };\n } catch (e: any) {\n throw new Error(`Corrupted or invalid continuation token: ${decodedToken}`);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n private extractOperationOptions<T extends OperationOptions>(\n obj: T\n ): {\n operationOptions: OperationOptions;\n restOptions: any;\n } {\n const { abortSignal, requestOptions, tracingOptions, ...restOptions } = obj;\n\n return {\n operationOptions: {\n abortSignal,\n requestOptions,\n tracingOptions,\n },\n restOptions,\n };\n }\n\n private convertSelect<Fields extends SelectFields<Model>>(select?: Fields[]): string | undefined {\n if (select) {\n return select.join(\",\");\n }\n return select;\n }\n\n private convertSearchFields(searchFields?: SelectFields<Model>[]): string | undefined {\n if (searchFields) {\n return searchFields.join(\",\");\n }\n return searchFields;\n }\n\n private convertSemanticFields(semanticFields?: string[]): string | undefined {\n if (semanticFields) {\n return semanticFields.join(\",\");\n }\n return semanticFields;\n }\n\n private convertOrderBy(orderBy?: string[]): string | undefined {\n if (orderBy) {\n return orderBy.join(\",\");\n }\n return orderBy;\n }\n}\n"]}
|