@azure/search-documents 12.0.0-alpha.20240110.1 → 12.0.0-alpha.20240112.1
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 +1081 -569
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/data/models/mappers.js +10 -4
- package/dist-esm/src/generated/data/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/data/searchClient.js +9 -3
- package/dist-esm/src/generated/data/searchClient.js.map +1 -1
- package/dist-esm/src/generated/service/models/mappers.js +642 -278
- package/dist-esm/src/generated/service/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClient.js +7 -3
- package/dist-esm/src/generated/service/searchServiceClient.js.map +1 -1
- package/dist-esm/src/indexDocumentsBatch.js +16 -4
- package/dist-esm/src/indexDocumentsBatch.js.map +1 -1
- package/dist-esm/src/searchClient.js +97 -68
- package/dist-esm/src/searchClient.js.map +1 -1
- package/dist-esm/src/searchIndexClient.js +116 -137
- package/dist-esm/src/searchIndexClient.js.map +1 -1
- package/dist-esm/src/searchIndexerClient.js +62 -25
- package/dist-esm/src/searchIndexerClient.js.map +1 -1
- package/dist-esm/src/searchIndexingBufferedSender.js +7 -8
- package/dist-esm/src/searchIndexingBufferedSender.js.map +1 -1
- package/dist-esm/src/serialization.js +1 -1
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/serviceUtils.js +112 -39
- package/dist-esm/src/serviceUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,6 @@ export class SearchIndexerClient {
|
|
|
32
32
|
* @param options - Used to configure the Search client.
|
|
33
33
|
*/
|
|
34
34
|
constructor(endpoint, credential, options = {}) {
|
|
35
|
-
var _a, _b;
|
|
36
35
|
/**
|
|
37
36
|
* The API version to use when communicating with the service.
|
|
38
37
|
*/
|
|
@@ -43,21 +42,24 @@ export class SearchIndexerClient {
|
|
|
43
42
|
*/
|
|
44
43
|
this.apiVersion = utils.defaultServiceVersion;
|
|
45
44
|
this.endpoint = endpoint;
|
|
46
|
-
const internalClientPipelineOptions =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
const internalClientPipelineOptions = {
|
|
46
|
+
...options,
|
|
47
|
+
...{
|
|
48
|
+
loggingOptions: {
|
|
49
|
+
logger: logger.info,
|
|
50
|
+
additionalAllowedHeaderNames: [
|
|
51
|
+
"elapsed-time",
|
|
52
|
+
"Location",
|
|
53
|
+
"OData-MaxVersion",
|
|
54
|
+
"OData-Version",
|
|
55
|
+
"Prefer",
|
|
56
|
+
"throttle-reason",
|
|
57
|
+
],
|
|
58
|
+
},
|
|
57
59
|
},
|
|
58
|
-
}
|
|
60
|
+
};
|
|
59
61
|
this.serviceVersion =
|
|
60
|
-
|
|
62
|
+
options.serviceVersion ?? options.apiVersion ?? utils.defaultServiceVersion;
|
|
61
63
|
this.apiVersion = this.serviceVersion;
|
|
62
64
|
this.client = new GeneratedClient(this.endpoint, this.serviceVersion, internalClientPipelineOptions);
|
|
63
65
|
if (isTokenCredential(credential)) {
|
|
@@ -99,7 +101,10 @@ export class SearchIndexerClient {
|
|
|
99
101
|
async listIndexersNames(options = {}) {
|
|
100
102
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-listIndexersNames", options);
|
|
101
103
|
try {
|
|
102
|
-
const result = await this.client.indexers.list(
|
|
104
|
+
const result = await this.client.indexers.list({
|
|
105
|
+
...updatedOptions,
|
|
106
|
+
select: "name",
|
|
107
|
+
});
|
|
103
108
|
return result.indexers.map((idx) => idx.name);
|
|
104
109
|
}
|
|
105
110
|
catch (e) {
|
|
@@ -141,7 +146,10 @@ export class SearchIndexerClient {
|
|
|
141
146
|
async listDataSourceConnectionsNames(options = {}) {
|
|
142
147
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-listDataSourceConnectionsNames", options);
|
|
143
148
|
try {
|
|
144
|
-
const result = await this.client.dataSources.list(
|
|
149
|
+
const result = await this.client.dataSources.list({
|
|
150
|
+
...updatedOptions,
|
|
151
|
+
select: "name",
|
|
152
|
+
});
|
|
145
153
|
return result.dataSources.map((ds) => ds.name);
|
|
146
154
|
}
|
|
147
155
|
catch (e) {
|
|
@@ -183,7 +191,10 @@ export class SearchIndexerClient {
|
|
|
183
191
|
async listSkillsetsNames(options = {}) {
|
|
184
192
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-listSkillsetsNames", options);
|
|
185
193
|
try {
|
|
186
|
-
const result = await this.client.skillsets.list(
|
|
194
|
+
const result = await this.client.skillsets.list({
|
|
195
|
+
...updatedOptions,
|
|
196
|
+
select: "name",
|
|
197
|
+
});
|
|
187
198
|
return result.skillsets.map((sks) => sks.name);
|
|
188
199
|
}
|
|
189
200
|
catch (e) {
|
|
@@ -338,7 +349,12 @@ export class SearchIndexerClient {
|
|
|
338
349
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-createOrUpdateIndexer", options);
|
|
339
350
|
try {
|
|
340
351
|
const etag = options.onlyIfUnchanged ? indexer.etag : undefined;
|
|
341
|
-
const result = await this.client.indexers.createOrUpdate(indexer.name, utils.publicSearchIndexerToGeneratedSearchIndexer(indexer),
|
|
352
|
+
const result = await this.client.indexers.createOrUpdate(indexer.name, utils.publicSearchIndexerToGeneratedSearchIndexer(indexer), {
|
|
353
|
+
...updatedOptions,
|
|
354
|
+
ifMatch: etag,
|
|
355
|
+
skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,
|
|
356
|
+
disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,
|
|
357
|
+
});
|
|
342
358
|
return utils.generatedSearchIndexerToPublicSearchIndexer(result);
|
|
343
359
|
}
|
|
344
360
|
catch (e) {
|
|
@@ -361,7 +377,11 @@ export class SearchIndexerClient {
|
|
|
361
377
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-createOrUpdateDataSourceConnection", options);
|
|
362
378
|
try {
|
|
363
379
|
const etag = options.onlyIfUnchanged ? dataSourceConnection.etag : undefined;
|
|
364
|
-
const result = await this.client.dataSources.createOrUpdate(dataSourceConnection.name, utils.publicDataSourceToGeneratedDataSource(dataSourceConnection),
|
|
380
|
+
const result = await this.client.dataSources.createOrUpdate(dataSourceConnection.name, utils.publicDataSourceToGeneratedDataSource(dataSourceConnection), {
|
|
381
|
+
...updatedOptions,
|
|
382
|
+
ifMatch: etag,
|
|
383
|
+
skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,
|
|
384
|
+
});
|
|
365
385
|
return utils.generatedDataSourceToPublicDataSource(result);
|
|
366
386
|
}
|
|
367
387
|
catch (e) {
|
|
@@ -384,7 +404,12 @@ export class SearchIndexerClient {
|
|
|
384
404
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-createOrUpdateSkillset", options);
|
|
385
405
|
try {
|
|
386
406
|
const etag = options.onlyIfUnchanged ? skillset.etag : undefined;
|
|
387
|
-
const result = await this.client.skillsets.createOrUpdate(skillset.name, utils.publicSkillsetToGeneratedSkillset(skillset),
|
|
407
|
+
const result = await this.client.skillsets.createOrUpdate(skillset.name, utils.publicSkillsetToGeneratedSkillset(skillset), {
|
|
408
|
+
...updatedOptions,
|
|
409
|
+
ifMatch: etag,
|
|
410
|
+
skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,
|
|
411
|
+
disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,
|
|
412
|
+
});
|
|
388
413
|
return utils.generatedSkillsetToPublicSkillset(result);
|
|
389
414
|
}
|
|
390
415
|
catch (e) {
|
|
@@ -412,7 +437,10 @@ export class SearchIndexerClient {
|
|
|
412
437
|
: options.onlyIfUnchanged
|
|
413
438
|
? indexer.etag
|
|
414
439
|
: undefined;
|
|
415
|
-
await this.client.indexers.delete(indexerName,
|
|
440
|
+
await this.client.indexers.delete(indexerName, {
|
|
441
|
+
...updatedOptions,
|
|
442
|
+
ifMatch: etag,
|
|
443
|
+
});
|
|
416
444
|
}
|
|
417
445
|
catch (e) {
|
|
418
446
|
span.setStatus({
|
|
@@ -439,7 +467,10 @@ export class SearchIndexerClient {
|
|
|
439
467
|
: options.onlyIfUnchanged
|
|
440
468
|
? dataSourceConnection.etag
|
|
441
469
|
: undefined;
|
|
442
|
-
await this.client.dataSources.delete(dataSourceConnectionName,
|
|
470
|
+
await this.client.dataSources.delete(dataSourceConnectionName, {
|
|
471
|
+
...updatedOptions,
|
|
472
|
+
ifMatch: etag,
|
|
473
|
+
});
|
|
443
474
|
}
|
|
444
475
|
catch (e) {
|
|
445
476
|
span.setStatus({
|
|
@@ -466,7 +497,10 @@ export class SearchIndexerClient {
|
|
|
466
497
|
: options.onlyIfUnchanged
|
|
467
498
|
? skillset.etag
|
|
468
499
|
: undefined;
|
|
469
|
-
await this.client.skillsets.delete(skillsetName,
|
|
500
|
+
await this.client.skillsets.delete(skillsetName, {
|
|
501
|
+
...updatedOptions,
|
|
502
|
+
ifMatch: etag,
|
|
503
|
+
});
|
|
470
504
|
}
|
|
471
505
|
catch (e) {
|
|
472
506
|
span.setStatus({
|
|
@@ -551,10 +585,13 @@ export class SearchIndexerClient {
|
|
|
551
585
|
async resetDocuments(indexerName, options = {}) {
|
|
552
586
|
const { span, updatedOptions } = createSpan("SearchIndexerClient-resetDocs", options);
|
|
553
587
|
try {
|
|
554
|
-
await this.client.indexers.resetDocs(indexerName,
|
|
588
|
+
await this.client.indexers.resetDocs(indexerName, {
|
|
589
|
+
...updatedOptions,
|
|
590
|
+
keysOrIds: {
|
|
555
591
|
documentKeys: updatedOptions.documentKeys,
|
|
556
592
|
datasourceDocumentIds: updatedOptions.datasourceDocumentIds,
|
|
557
|
-
}
|
|
593
|
+
},
|
|
594
|
+
});
|
|
558
595
|
}
|
|
559
596
|
catch (e) {
|
|
560
597
|
span.setStatus({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchIndexerClient.js","sourceRoot":"","sources":["../../src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EAAE,UAA8B,EAAE;QAC7E,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;QACxF,IAAI;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACrC,YAAY,EACZ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAClC,cAAc,CACf,CAAC;SACH;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC,CAAC,OAAO;aACjB,CAAC,CAAC;YACH,MAAM,CAAC,CAAC;SACT;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalClientPipelineOptions } from \"@azure/core-client\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { SearchIndexerStatus } from \"./generated/service/models\";\nimport { SearchServiceClient as GeneratedClient } from \"./generated/service/searchServiceClient\";\nimport { logger } from \"./logger\";\nimport { createSearchApiKeyCredentialPolicy } from \"./searchApiKeyCredentialPolicy\";\nimport {\n CreateDataSourceConnectionOptions,\n CreateIndexerOptions,\n CreateOrUpdateSkillsetOptions,\n CreateSkillsetOptions,\n CreateorUpdateDataSourceConnectionOptions,\n CreateorUpdateIndexerOptions,\n DeleteDataSourceConnectionOptions,\n DeleteIndexerOptions,\n DeleteSkillsetOptions,\n GetDataSourceConnectionOptions,\n GetIndexerOptions,\n GetIndexerStatusOptions,\n GetSkillSetOptions,\n ListDataSourceConnectionsOptions,\n ListIndexersOptions,\n ListSkillsetsOptions,\n ResetDocumentsOptions,\n ResetIndexerOptions,\n ResetSkillsOptions,\n RunIndexerOptions,\n SearchIndexer,\n SearchIndexerDataSourceConnection,\n SearchIndexerSkillset,\n} from \"./serviceModels\";\nimport * as utils from \"./serviceUtils\";\nimport { createSpan } from \"./tracing\";\nimport { createOdataMetadataPolicy } from \"./odataMetadataPolicy\";\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 SearchIndexerClientOptions 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 to perform operations to manage\n * (create, update, list/delete)\n * indexers, datasources & skillsets.\n */\nexport class SearchIndexerClient {\n /**\n * The API 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 * @internal\n * @hidden\n * A reference to the auto-generated SearchServiceClient\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of SearchIndexerClient.\n *\n * Example usage:\n * ```ts\n * const { SearchIndexerClient, AzureKeyCredential } = require(\"@azure/search-documents\");\n *\n * const client = new SearchIndexerClient(\n * \"<endpoint>\",\n * new AzureKeyCredential(\"<Admin Key>\");\n * );\n * ```\n * @param endpoint - The endpoint of the search service\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Search client.\n */\n constructor(\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options: SearchIndexerClientOptions = {},\n ) {\n this.endpoint = endpoint;\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.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(\"minimal\"));\n }\n\n /**\n * Retrieves a list of existing indexers in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listIndexers(options: ListIndexersOptions = {}): Promise<Array<SearchIndexer>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listIndexers\", options);\n try {\n const result = await this.client.indexers.list(updatedOptions);\n return result.indexers.map(utils.generatedSearchIndexerToPublicSearchIndexer);\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 * Retrieves a list of names of existing indexers in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listIndexersNames(options: ListIndexersOptions = {}): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listIndexersNames\", options);\n try {\n const result = await this.client.indexers.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.indexers.map((idx) => idx.name);\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 * Retrieves a list of existing data sources in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listDataSourceConnections(\n options: ListDataSourceConnectionsOptions = {},\n ): Promise<Array<SearchIndexerDataSourceConnection>> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-listDataSourceConnections\",\n options,\n );\n try {\n const result = await this.client.dataSources.list(updatedOptions);\n return result.dataSources.map(utils.generatedDataSourceToPublicDataSource);\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 * Retrieves a list of names of existing data sources in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listDataSourceConnectionsNames(\n options: ListDataSourceConnectionsOptions = {},\n ): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-listDataSourceConnectionsNames\",\n options,\n );\n try {\n const result = await this.client.dataSources.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.dataSources.map((ds) => ds.name);\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 * Retrieves a list of existing Skillsets in the service.\n * @param options - Options to the list Skillsets operation.\n */\n public async listSkillsets(\n options: ListSkillsetsOptions = {},\n ): Promise<Array<SearchIndexerSkillset>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listSkillsets\", options);\n try {\n const result = await this.client.skillsets.list(updatedOptions);\n return result.skillsets.map(utils.generatedSkillsetToPublicSkillset);\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 * Retrieves a list of names of existing Skillsets in the service.\n * @param options - Options to the list Skillsets operation.\n */\n public async listSkillsetsNames(options: ListSkillsetsOptions = {}): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listSkillsetsNames\", options);\n try {\n const result = await this.client.skillsets.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.skillsets.map((sks) => sks.name);\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 * Retrieves information about an Indexer.\n * @param indexerName - The name of the Indexer.\n * @param options - Additional optional arguments.\n */\n public async getIndexer(\n indexerName: string,\n options: GetIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getIndexer\", options);\n try {\n const result = await this.client.indexers.get(indexerName, updatedOptions);\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Retrieves information about a DataSource\n * @param dataSourceName - The name of the DataSource\n * @param options - Additional optional arguments\n */\n public async getDataSourceConnection(\n dataSourceConnectionName: string,\n options: GetDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-getDataSourceConnection\",\n options,\n );\n try {\n const result = await this.client.dataSources.get(dataSourceConnectionName, updatedOptions);\n return utils.generatedDataSourceToPublicDataSource(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 * Retrieves information about an Skillset.\n * @param indexName - The name of the Skillset.\n * @param options - Additional optional arguments.\n */\n public async getSkillset(\n skillsetName: string,\n options: GetSkillSetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getSkillset\", options);\n try {\n const result = await this.client.skillsets.get(skillsetName, updatedOptions);\n return utils.generatedSkillsetToPublicSkillset(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 * Creates a new indexer in a search service.\n * @param indexer - The indexer definition to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createIndexer(\n indexer: SearchIndexer,\n options: CreateIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-createIndexer\", options);\n try {\n const result = await this.client.indexers.create(\n utils.publicSearchIndexerToGeneratedSearchIndexer(indexer),\n updatedOptions,\n );\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Creates a new dataSource in a search service.\n * @param dataSourceConnection - The dataSource definition to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createDataSourceConnection(\n dataSourceConnection: SearchIndexerDataSourceConnection,\n options: CreateDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createDataSourceConnection\",\n options,\n );\n try {\n const result = await this.client.dataSources.create(\n utils.publicDataSourceToGeneratedDataSource(dataSourceConnection),\n updatedOptions,\n );\n return utils.generatedDataSourceToPublicDataSource(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 * Creates a new skillset in a search service.\n * @param skillset - The skillset containing one or more skills to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createSkillset(\n skillset: SearchIndexerSkillset,\n options: CreateSkillsetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-createSkillset\", options);\n try {\n const result = await this.client.skillsets.create(\n utils.publicSkillsetToGeneratedSkillset(skillset),\n updatedOptions,\n );\n return utils.generatedSkillsetToPublicSkillset(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 * Creates a new indexer or modifies an existing one.\n * @param indexer - The information describing the indexer to be created/updated.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateIndexer(\n indexer: SearchIndexer,\n options: CreateorUpdateIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateIndexer\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? indexer.etag : undefined;\n\n const result = await this.client.indexers.createOrUpdate(\n indexer.name,\n utils.publicSearchIndexerToGeneratedSearchIndexer(indexer),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,\n },\n );\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Creates a new datasource or modifies an existing one.\n * @param dataSourceConnection - The information describing the datasource to be created/updated.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateDataSourceConnection(\n dataSourceConnection: SearchIndexerDataSourceConnection,\n options: CreateorUpdateDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateDataSourceConnection\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? dataSourceConnection.etag : undefined;\n\n const result = await this.client.dataSources.createOrUpdate(\n dataSourceConnection.name,\n utils.publicDataSourceToGeneratedDataSource(dataSourceConnection),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n },\n );\n return utils.generatedDataSourceToPublicDataSource(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 * Creates a new Skillset or modifies an existing one.\n * @param skillset - The information describing the index to be created.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateSkillset(\n skillset: SearchIndexerSkillset,\n options: CreateOrUpdateSkillsetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateSkillset\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? skillset.etag : undefined;\n\n const result = await this.client.skillsets.createOrUpdate(\n skillset.name,\n utils.publicSkillsetToGeneratedSkillset(skillset),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,\n },\n );\n\n return utils.generatedSkillsetToPublicSkillset(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 * Deletes an existing indexer.\n * @param indexer - Indexer/Name of the indexer to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteIndexer(\n indexer: string | SearchIndexer,\n options: DeleteIndexerOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-deleteIndexer\", options);\n try {\n const indexerName: string = typeof indexer === \"string\" ? indexer : indexer.name;\n const etag =\n typeof indexer === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? indexer.etag\n : undefined;\n\n await this.client.indexers.delete(indexerName, {\n ...updatedOptions,\n ifMatch: etag,\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 * Deletes an existing datasource.\n * @param dataSource - Datasource/Name of the datasource to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteDataSourceConnection(\n dataSourceConnection: string | SearchIndexerDataSourceConnection,\n options: DeleteDataSourceConnectionOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-deleteDataSourceConnection\",\n options,\n );\n try {\n const dataSourceConnectionName: string =\n typeof dataSourceConnection === \"string\" ? dataSourceConnection : dataSourceConnection.name;\n const etag =\n typeof dataSourceConnection === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? dataSourceConnection.etag\n : undefined;\n\n await this.client.dataSources.delete(dataSourceConnectionName, {\n ...updatedOptions,\n ifMatch: etag,\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 * Deletes an existing Skillset.\n * @param skillset - Skillset/Name of the Skillset to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteSkillset(\n skillset: string | SearchIndexerSkillset,\n options: DeleteSkillsetOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-deleteSkillset\", options);\n try {\n const skillsetName: string = typeof skillset === \"string\" ? skillset : skillset.name;\n const etag =\n typeof skillset === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? skillset.etag\n : undefined;\n\n await this.client.skillsets.delete(skillsetName, {\n ...updatedOptions,\n ifMatch: etag,\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 the current status and execution history of an indexer.\n * @param indexerName - The name of the indexer.\n * @param options - Additional optional arguments.\n */\n public async getIndexerStatus(\n indexerName: string,\n options: GetIndexerStatusOptions = {},\n ): Promise<SearchIndexerStatus> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getIndexerStatus\", options);\n try {\n const result = await this.client.indexers.getStatus(indexerName, 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 /**\n * Resets the change tracking state associated with an indexer.\n * @param indexerName - The name of the indexer to reset.\n * @param options - Additional optional arguments.\n */\n public async resetIndexer(indexerName: string, options: ResetIndexerOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetIndexer\", options);\n try {\n await this.client.indexers.reset(indexerName, 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 * Runs an indexer on-demand.\n * @param indexerName - The name of the indexer to run.\n * @param options - Additional optional arguments.\n */\n public async runIndexer(indexerName: string, options: RunIndexerOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-runIndexer\", options);\n try {\n await this.client.indexers.run(indexerName, 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 * Resets specific documents in the datasource to be selectively re-ingested by the indexer.\n * @param indexerName - The name of the indexer to reset documents for.\n * @param options - Additional optional arguments.\n */\n public async resetDocuments(\n indexerName: string,\n options: ResetDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetDocs\", options);\n try {\n await this.client.indexers.resetDocs(indexerName, {\n ...updatedOptions,\n keysOrIds: {\n documentKeys: updatedOptions.documentKeys,\n datasourceDocumentIds: updatedOptions.datasourceDocumentIds,\n },\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 * Reset an existing skillset in a search service.\n * @param skillsetName - The name of the skillset to reset.\n * @param skillNames - The names of skills to reset.\n * @param options - The options parameters.\n */\n public async resetSkills(skillsetName: string, options: ResetSkillsOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetSkills\", options);\n try {\n await this.client.skillsets.resetSkills(\n skillsetName,\n { skillNames: options.skillNames },\n 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"]}
|
|
1
|
+
{"version":3,"file":"searchIndexerClient.js","sourceRoot":"","sources":["../../src/searchIndexerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,O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AW,CAAC,YAAoB,EAAE,UAA8B,EAAE;QAC7E,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;QACxF,IAAI;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACrC,YAAY,EACZ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAClC,cAAc,CACf,CAAC;SACH;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC,CAAC,OAAO;aACjB,CAAC,CAAC;YACH,MAAM,CAAC,CAAC;SACT;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalClientPipelineOptions } from \"@azure/core-client\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { SearchIndexerStatus } from \"./generated/service/models\";\nimport { SearchServiceClient as GeneratedClient } from \"./generated/service/searchServiceClient\";\nimport { logger } from \"./logger\";\nimport { createSearchApiKeyCredentialPolicy } from \"./searchApiKeyCredentialPolicy\";\nimport {\n CreateDataSourceConnectionOptions,\n CreateIndexerOptions,\n CreateOrUpdateSkillsetOptions,\n CreateSkillsetOptions,\n CreateorUpdateDataSourceConnectionOptions,\n CreateorUpdateIndexerOptions,\n DeleteDataSourceConnectionOptions,\n DeleteIndexerOptions,\n DeleteSkillsetOptions,\n GetDataSourceConnectionOptions,\n GetIndexerOptions,\n GetIndexerStatusOptions,\n GetSkillSetOptions,\n ListDataSourceConnectionsOptions,\n ListIndexersOptions,\n ListSkillsetsOptions,\n ResetDocumentsOptions,\n ResetIndexerOptions,\n ResetSkillsOptions,\n RunIndexerOptions,\n SearchIndexer,\n SearchIndexerDataSourceConnection,\n SearchIndexerSkillset,\n} from \"./serviceModels\";\nimport * as utils from \"./serviceUtils\";\nimport { createSpan } from \"./tracing\";\nimport { createOdataMetadataPolicy } from \"./odataMetadataPolicy\";\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 SearchIndexerClientOptions 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 to perform operations to manage\n * (create, update, list/delete)\n * indexers, datasources & skillsets.\n */\nexport class SearchIndexerClient {\n /**\n * The API 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 * @internal\n * @hidden\n * A reference to the auto-generated SearchServiceClient\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of SearchIndexerClient.\n *\n * Example usage:\n * ```ts\n * const { SearchIndexerClient, AzureKeyCredential } = require(\"@azure/search-documents\");\n *\n * const client = new SearchIndexerClient(\n * \"<endpoint>\",\n * new AzureKeyCredential(\"<Admin Key>\");\n * );\n * ```\n * @param endpoint - The endpoint of the search service\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Search client.\n */\n constructor(\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options: SearchIndexerClientOptions = {},\n ) {\n this.endpoint = endpoint;\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.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(\"minimal\"));\n }\n\n /**\n * Retrieves a list of existing indexers in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listIndexers(options: ListIndexersOptions = {}): Promise<Array<SearchIndexer>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listIndexers\", options);\n try {\n const result = await this.client.indexers.list(updatedOptions);\n return result.indexers.map(utils.generatedSearchIndexerToPublicSearchIndexer);\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 * Retrieves a list of names of existing indexers in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listIndexersNames(options: ListIndexersOptions = {}): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listIndexersNames\", options);\n try {\n const result = await this.client.indexers.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.indexers.map((idx) => idx.name);\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 * Retrieves a list of existing data sources in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listDataSourceConnections(\n options: ListDataSourceConnectionsOptions = {},\n ): Promise<Array<SearchIndexerDataSourceConnection>> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-listDataSourceConnections\",\n options,\n );\n try {\n const result = await this.client.dataSources.list(updatedOptions);\n return result.dataSources.map(utils.generatedDataSourceToPublicDataSource);\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 * Retrieves a list of names of existing data sources in the service.\n * @param options - Options to the list indexers operation.\n */\n public async listDataSourceConnectionsNames(\n options: ListDataSourceConnectionsOptions = {},\n ): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-listDataSourceConnectionsNames\",\n options,\n );\n try {\n const result = await this.client.dataSources.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.dataSources.map((ds) => ds.name);\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 * Retrieves a list of existing Skillsets in the service.\n * @param options - Options to the list Skillsets operation.\n */\n public async listSkillsets(\n options: ListSkillsetsOptions = {},\n ): Promise<Array<SearchIndexerSkillset>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listSkillsets\", options);\n try {\n const result = await this.client.skillsets.list(updatedOptions);\n return result.skillsets.map(utils.generatedSkillsetToPublicSkillset);\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 * Retrieves a list of names of existing Skillsets in the service.\n * @param options - Options to the list Skillsets operation.\n */\n public async listSkillsetsNames(options: ListSkillsetsOptions = {}): Promise<Array<string>> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-listSkillsetsNames\", options);\n try {\n const result = await this.client.skillsets.list({\n ...updatedOptions,\n select: \"name\",\n });\n return result.skillsets.map((sks) => sks.name);\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 * Retrieves information about an Indexer.\n * @param indexerName - The name of the Indexer.\n * @param options - Additional optional arguments.\n */\n public async getIndexer(\n indexerName: string,\n options: GetIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getIndexer\", options);\n try {\n const result = await this.client.indexers.get(indexerName, updatedOptions);\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Retrieves information about a DataSource\n * @param dataSourceName - The name of the DataSource\n * @param options - Additional optional arguments\n */\n public async getDataSourceConnection(\n dataSourceConnectionName: string,\n options: GetDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-getDataSourceConnection\",\n options,\n );\n try {\n const result = await this.client.dataSources.get(dataSourceConnectionName, updatedOptions);\n return utils.generatedDataSourceToPublicDataSource(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 * Retrieves information about an Skillset.\n * @param indexName - The name of the Skillset.\n * @param options - Additional optional arguments.\n */\n public async getSkillset(\n skillsetName: string,\n options: GetSkillSetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getSkillset\", options);\n try {\n const result = await this.client.skillsets.get(skillsetName, updatedOptions);\n return utils.generatedSkillsetToPublicSkillset(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 * Creates a new indexer in a search service.\n * @param indexer - The indexer definition to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createIndexer(\n indexer: SearchIndexer,\n options: CreateIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-createIndexer\", options);\n try {\n const result = await this.client.indexers.create(\n utils.publicSearchIndexerToGeneratedSearchIndexer(indexer),\n updatedOptions,\n );\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Creates a new dataSource in a search service.\n * @param dataSourceConnection - The dataSource definition to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createDataSourceConnection(\n dataSourceConnection: SearchIndexerDataSourceConnection,\n options: CreateDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createDataSourceConnection\",\n options,\n );\n try {\n const result = await this.client.dataSources.create(\n utils.publicDataSourceToGeneratedDataSource(dataSourceConnection),\n updatedOptions,\n );\n return utils.generatedDataSourceToPublicDataSource(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 * Creates a new skillset in a search service.\n * @param skillset - The skillset containing one or more skills to create in a search service.\n * @param options - Additional optional arguments.\n */\n public async createSkillset(\n skillset: SearchIndexerSkillset,\n options: CreateSkillsetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-createSkillset\", options);\n try {\n const result = await this.client.skillsets.create(\n utils.publicSkillsetToGeneratedSkillset(skillset),\n updatedOptions,\n );\n return utils.generatedSkillsetToPublicSkillset(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 * Creates a new indexer or modifies an existing one.\n * @param indexer - The information describing the indexer to be created/updated.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateIndexer(\n indexer: SearchIndexer,\n options: CreateorUpdateIndexerOptions = {},\n ): Promise<SearchIndexer> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateIndexer\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? indexer.etag : undefined;\n\n const result = await this.client.indexers.createOrUpdate(\n indexer.name,\n utils.publicSearchIndexerToGeneratedSearchIndexer(indexer),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,\n },\n );\n return utils.generatedSearchIndexerToPublicSearchIndexer(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 * Creates a new datasource or modifies an existing one.\n * @param dataSourceConnection - The information describing the datasource to be created/updated.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateDataSourceConnection(\n dataSourceConnection: SearchIndexerDataSourceConnection,\n options: CreateorUpdateDataSourceConnectionOptions = {},\n ): Promise<SearchIndexerDataSourceConnection> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateDataSourceConnection\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? dataSourceConnection.etag : undefined;\n\n const result = await this.client.dataSources.createOrUpdate(\n dataSourceConnection.name,\n utils.publicDataSourceToGeneratedDataSource(dataSourceConnection),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n },\n );\n return utils.generatedDataSourceToPublicDataSource(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 * Creates a new Skillset or modifies an existing one.\n * @param skillset - The information describing the index to be created.\n * @param options - Additional optional arguments.\n */\n public async createOrUpdateSkillset(\n skillset: SearchIndexerSkillset,\n options: CreateOrUpdateSkillsetOptions = {},\n ): Promise<SearchIndexerSkillset> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-createOrUpdateSkillset\",\n options,\n );\n try {\n const etag = options.onlyIfUnchanged ? skillset.etag : undefined;\n\n const result = await this.client.skillsets.createOrUpdate(\n skillset.name,\n utils.publicSkillsetToGeneratedSkillset(skillset),\n {\n ...updatedOptions,\n ifMatch: etag,\n skipIndexerResetRequirementForCache: options.skipIndexerResetRequirementForCache,\n disableCacheReprocessingChangeDetection: options.disableCacheReprocessingChangeDetection,\n },\n );\n\n return utils.generatedSkillsetToPublicSkillset(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 * Deletes an existing indexer.\n * @param indexer - Indexer/Name of the indexer to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteIndexer(\n indexer: string | SearchIndexer,\n options: DeleteIndexerOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-deleteIndexer\", options);\n try {\n const indexerName: string = typeof indexer === \"string\" ? indexer : indexer.name;\n const etag =\n typeof indexer === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? indexer.etag\n : undefined;\n\n await this.client.indexers.delete(indexerName, {\n ...updatedOptions,\n ifMatch: etag,\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 * Deletes an existing datasource.\n * @param dataSource - Datasource/Name of the datasource to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteDataSourceConnection(\n dataSourceConnection: string | SearchIndexerDataSourceConnection,\n options: DeleteDataSourceConnectionOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexerClient-deleteDataSourceConnection\",\n options,\n );\n try {\n const dataSourceConnectionName: string =\n typeof dataSourceConnection === \"string\" ? dataSourceConnection : dataSourceConnection.name;\n const etag =\n typeof dataSourceConnection === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? dataSourceConnection.etag\n : undefined;\n\n await this.client.dataSources.delete(dataSourceConnectionName, {\n ...updatedOptions,\n ifMatch: etag,\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 * Deletes an existing Skillset.\n * @param skillset - Skillset/Name of the Skillset to delete.\n * @param options - Additional optional arguments.\n */\n public async deleteSkillset(\n skillset: string | SearchIndexerSkillset,\n options: DeleteSkillsetOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-deleteSkillset\", options);\n try {\n const skillsetName: string = typeof skillset === \"string\" ? skillset : skillset.name;\n const etag =\n typeof skillset === \"string\"\n ? undefined\n : options.onlyIfUnchanged\n ? skillset.etag\n : undefined;\n\n await this.client.skillsets.delete(skillsetName, {\n ...updatedOptions,\n ifMatch: etag,\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 the current status and execution history of an indexer.\n * @param indexerName - The name of the indexer.\n * @param options - Additional optional arguments.\n */\n public async getIndexerStatus(\n indexerName: string,\n options: GetIndexerStatusOptions = {},\n ): Promise<SearchIndexerStatus> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-getIndexerStatus\", options);\n try {\n const result = await this.client.indexers.getStatus(indexerName, 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 /**\n * Resets the change tracking state associated with an indexer.\n * @param indexerName - The name of the indexer to reset.\n * @param options - Additional optional arguments.\n */\n public async resetIndexer(indexerName: string, options: ResetIndexerOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetIndexer\", options);\n try {\n await this.client.indexers.reset(indexerName, 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 * Runs an indexer on-demand.\n * @param indexerName - The name of the indexer to run.\n * @param options - Additional optional arguments.\n */\n public async runIndexer(indexerName: string, options: RunIndexerOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-runIndexer\", options);\n try {\n await this.client.indexers.run(indexerName, 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 * Resets specific documents in the datasource to be selectively re-ingested by the indexer.\n * @param indexerName - The name of the indexer to reset documents for.\n * @param options - Additional optional arguments.\n */\n public async resetDocuments(\n indexerName: string,\n options: ResetDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetDocs\", options);\n try {\n await this.client.indexers.resetDocs(indexerName, {\n ...updatedOptions,\n keysOrIds: {\n documentKeys: updatedOptions.documentKeys,\n datasourceDocumentIds: updatedOptions.datasourceDocumentIds,\n },\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 * Reset an existing skillset in a search service.\n * @param skillsetName - The name of the skillset to reset.\n * @param skillNames - The names of skills to reset.\n * @param options - The options parameters.\n */\n public async resetSkills(skillsetName: string, options: ResetSkillsOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexerClient-resetSkills\", options);\n try {\n await this.client.skillsets.resetSkills(\n skillsetName,\n { skillNames: options.skillNames },\n 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"]}
|
|
@@ -38,7 +38,6 @@ export class SearchIndexingBufferedSender {
|
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
40
40
|
constructor(client, documentKeyRetriever, options = {}) {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f;
|
|
42
41
|
/**
|
|
43
42
|
* Event emitter/publisher used in the Buffered Sender
|
|
44
43
|
*/
|
|
@@ -46,17 +45,17 @@ export class SearchIndexingBufferedSender {
|
|
|
46
45
|
this.client = client;
|
|
47
46
|
this.documentKeyRetriever = documentKeyRetriever;
|
|
48
47
|
// General Configuration properties
|
|
49
|
-
this.autoFlush =
|
|
50
|
-
this.initialBatchActionCount =
|
|
51
|
-
this.flushWindowInMs =
|
|
48
|
+
this.autoFlush = options.autoFlush ?? true;
|
|
49
|
+
this.initialBatchActionCount = options.initialBatchActionCount ?? DEFAULT_BATCH_SIZE;
|
|
50
|
+
this.flushWindowInMs = options.flushWindowInMs ?? DEFAULT_FLUSH_WINDOW;
|
|
52
51
|
// Retry specific configuration properties
|
|
53
|
-
this.throttlingDelayInMs =
|
|
54
|
-
this.maxRetriesPerAction =
|
|
55
|
-
this.maxThrottlingDelayInMs =
|
|
52
|
+
this.throttlingDelayInMs = options.throttlingDelayInMs ?? DEFAULT_FLUSH_WINDOW;
|
|
53
|
+
this.maxRetriesPerAction = options.maxRetriesPerAction ?? DEFAULT_RETRY_COUNT;
|
|
54
|
+
this.maxThrottlingDelayInMs = options.maxThrottlingDelayInMs ?? DEFAULT_MAX_RETRY_DELAY;
|
|
56
55
|
this.batchObject = new IndexDocumentsBatch();
|
|
57
56
|
if (this.autoFlush) {
|
|
58
57
|
const interval = setInterval(() => this.flush(), this.flushWindowInMs);
|
|
59
|
-
interval
|
|
58
|
+
interval?.unref();
|
|
60
59
|
this.cleanupTimer = () => {
|
|
61
60
|
clearInterval(interval);
|
|
62
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchIndexingBufferedSender.js","sourceRoot":"","sources":["../../src/searchIndexingBufferedSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAa5D,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAA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iBAAiB,EAAE;oBACvC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAC9C;aACF;iBAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC/E,6CAA6C;gBAC7C,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;gBAC9E,yCAAyC;gBACzC,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;gBACxF,gFAAgF;gBAChF,mEAAmE;gBACnE,MAAM,eAAe,GACnB,uBAAuB,GAAG,CAAC,GAAG,yBAAyB,CAAC,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,CAAC;gBAC1F,MAAM,KAAK,CAAC,eAAe,CAAC,CAAC;gBAC7B,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;aACtE;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;gBACpC,MAAM,CAAC,CAAC;aACT;SACF;IACH,CAAC;IAEO,gBAAgB,CAAC,CAAM;QAC7B,OAAO,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { IndexDocumentsBatch } from \"./indexDocumentsBatch\";\nimport {\n IndexDocumentsAction,\n IndexDocumentsOptions,\n SearchIndexingBufferedSenderDeleteDocumentsOptions,\n SearchIndexingBufferedSenderFlushDocumentsOptions,\n SearchIndexingBufferedSenderMergeDocumentsOptions,\n SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions,\n SearchIndexingBufferedSenderOptions,\n SearchIndexingBufferedSenderUploadDocumentsOptions,\n} from \"./indexModels\";\nimport { IndexDocumentsResult } from \"./generated/data/models\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport EventEmitter from \"events\";\nimport { createSpan } from \"./tracing\";\nimport { delay } from \"./serviceUtils\";\nimport { getRandomIntegerInclusive } from \"./serviceUtils\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\n/**\n * Index Documents Client\n */\nexport interface IndexDocumentsClient<T extends object> {\n /**\n * Perform a set of index modifications (upload, merge, mergeOrUpload, delete)\n * for the given set of documents.\n *\n * @param batch - An array of actions to perform on the index.\n * @param options - Additional options.\n */\n indexDocuments(\n batch: IndexDocumentsBatch<T>,\n options: IndexDocumentsOptions,\n ): Promise<IndexDocumentsResult>;\n}\n\n/**\n * Default Batch Size\n */\nexport const DEFAULT_BATCH_SIZE: number = 512;\n/**\n * Default window flush interval\n */\nexport const DEFAULT_FLUSH_WINDOW: number = 60000;\n/**\n * Default number of times to retry.\n */\nexport const DEFAULT_RETRY_COUNT: number = 3;\n/**\n * Default retry delay.\n */\nexport const DEFAULT_RETRY_DELAY: number = 800;\n/**\n * Default Max Delay between retries.\n */\nexport const DEFAULT_MAX_RETRY_DELAY: number = 60000;\n\n/**\n * Class used to perform buffered operations against a search index,\n * including adding, updating, and removing them.\n */\nexport class SearchIndexingBufferedSender<TModel extends object> {\n /**\n * Search Client used to call the underlying IndexBatch operations.\n */\n private client: IndexDocumentsClient<TModel>;\n /**\n * Indicates if autoFlush is enabled.\n */\n private autoFlush: boolean;\n /**\n * Interval between flushes (in milliseconds).\n */\n private flushWindowInMs: number;\n /**\n * Delay between retries\n */\n private throttlingDelayInMs: number;\n /**\n * Maximum number of Retries\n */\n private maxRetriesPerAction: number;\n /**\n * Max Delay between retries\n */\n private maxThrottlingDelayInMs: number;\n /**\n * Size of the batch.\n */\n private initialBatchActionCount: number;\n /**\n * Batch object used to complete the service call.\n */\n private batchObject: IndexDocumentsBatch<TModel>;\n /**\n * Clean up for the timer\n */\n private cleanupTimer?: () => void;\n /**\n * Event emitter/publisher used in the Buffered Sender\n */\n private readonly emitter = new EventEmitter();\n /**\n * Method to retrieve the document key\n */\n private documentKeyRetriever: (document: TModel) => string;\n\n /**\n * Creates a new instance of SearchIndexingBufferedSender.\n *\n * @param client - Search Client used to call the underlying IndexBatch operations.\n * @param options - Options to modify auto flush.\n *\n */\n constructor(\n client: IndexDocumentsClient<TModel>,\n documentKeyRetriever: (document: TModel) => string,\n options: SearchIndexingBufferedSenderOptions = {},\n ) {\n this.client = client;\n this.documentKeyRetriever = documentKeyRetriever;\n // General Configuration properties\n this.autoFlush = options.autoFlush ?? true;\n this.initialBatchActionCount = options.initialBatchActionCount ?? DEFAULT_BATCH_SIZE;\n this.flushWindowInMs = options.flushWindowInMs ?? DEFAULT_FLUSH_WINDOW;\n // Retry specific configuration properties\n this.throttlingDelayInMs = options.throttlingDelayInMs ?? DEFAULT_FLUSH_WINDOW;\n this.maxRetriesPerAction = options.maxRetriesPerAction ?? DEFAULT_RETRY_COUNT;\n this.maxThrottlingDelayInMs = options.maxThrottlingDelayInMs ?? DEFAULT_MAX_RETRY_DELAY;\n\n this.batchObject = new IndexDocumentsBatch<TModel>();\n if (this.autoFlush) {\n const interval = setInterval(() => this.flush(), this.flushWindowInMs);\n interval?.unref();\n this.cleanupTimer = () => {\n clearInterval(interval);\n };\n }\n }\n\n /**\n * Uploads the documents/Adds the documents to the upload queue.\n *\n * @param documents - Documents to be uploaded.\n * @param options - Upload options.\n */\n public async uploadDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderUploadDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-uploadDocuments\",\n options,\n );\n try {\n this.batchObject.upload(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"upload\",\n documents,\n });\n return this.internalFlush(false, 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 * Merges the documents/Adds the documents to the merge queue.\n *\n * @param documents - Documents to be merged.\n * @param options - Upload options.\n */\n public async mergeDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderMergeDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-mergeDocuments\",\n options,\n );\n try {\n this.batchObject.merge(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"merge\",\n documents,\n });\n return this.internalFlush(false, 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 * Merges/Uploads the documents/Adds the documents to the merge/upload queue.\n *\n * @param documents - Documents to be merged/uploaded.\n * @param options - Upload options.\n */\n public async mergeOrUploadDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-mergeOrUploadDocuments\",\n options,\n );\n try {\n this.batchObject.mergeOrUpload(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"mergeOrUpload\",\n documents,\n });\n return this.internalFlush(false, 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 * Deletes the documents/Adds the documents to the delete queue.\n *\n * @param documents - Documents to be deleted.\n * @param options - Upload options.\n */\n public async deleteDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderDeleteDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-deleteDocuments\",\n options,\n );\n try {\n this.batchObject.delete(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"delete\",\n documents,\n });\n return this.internalFlush(false, 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 * Flushes the queue manually.\n *\n * @param options - Flush options.\n */\n public async flush(\n options: SearchIndexingBufferedSenderFlushDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexingBufferedSender-flush\", options);\n try {\n if (this.batchObject.actions.length > 0) {\n return this.internalFlush(true, 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 * If using autoFlush: true, call this to cleanup the autoflush timer.\n */\n public async dispose(): Promise<void> {\n if (this.batchObject.actions.length > 0) {\n await this.internalFlush(true);\n }\n if (this.cleanupTimer) {\n this.cleanupTimer();\n }\n }\n\n /**\n * Attach Batch Added Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(\n event: \"batchAdded\",\n listener: (e: { action: string; documents: TModel[] }) => void,\n ): void;\n /**\n * Attach Batch Sent Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"beforeDocumentSent\", listener: (e: IndexDocumentsAction<TModel>) => void): void;\n /**\n * Attach Batch Succeeded Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"batchSucceeded\", listener: (e: IndexDocumentsResult) => void): void;\n /**\n * Attach Batch Failed Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"batchFailed\", listener: (e: RestError) => void): void;\n public on(\n event: \"batchAdded\" | \"beforeDocumentSent\" | \"batchSucceeded\" | \"batchFailed\" | \"batchResizing\",\n listener: (e: any) => void,\n ): void {\n this.emitter.on(event, listener);\n }\n\n /**\n * Detach Batch Added Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(\n event: \"batchAdded\",\n listener: (e: { action: string; documents: TModel[] }) => void,\n ): void;\n /**\n * Detach Batch Sent Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(\n event: \"beforeDocumentSent\",\n listener: (e: IndexDocumentsAction<TModel>) => void,\n ): void;\n /**\n * Detach Batch Succeeded Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(event: \"batchSucceeded\", listener: (e: IndexDocumentsResult) => void): void;\n /**\n * Detach Batch Failed Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(event: \"batchFailed\", listener: (e: RestError) => void): void;\n public off(\n event: \"batchAdded\" | \"beforeDocumentSent\" | \"batchSucceeded\" | \"batchFailed\",\n listener: (e: any) => void,\n ): void {\n this.emitter.removeListener(event, listener);\n }\n\n private isBatchReady(): boolean {\n return this.batchObject.actions.length >= this.initialBatchActionCount;\n }\n\n private async internalFlush(force: boolean, options: OperationOptions = {}): Promise<void> {\n if (force || (this.autoFlush && this.isBatchReady())) {\n // Split it\n const actions: IndexDocumentsAction<TModel>[] = this.batchObject.actions;\n this.batchObject = new IndexDocumentsBatch<TModel>();\n while (actions.length > 0) {\n const actionsToSend = actions.splice(0, this.initialBatchActionCount);\n const { batchToSubmit, submitLater } = this.pruneActions(actionsToSend);\n actions.unshift(...submitLater);\n await this.submitDocuments(batchToSubmit, options);\n }\n }\n }\n\n private pruneActions(batch: IndexDocumentsAction<TModel>[]): {\n batchToSubmit: IndexDocumentsAction<TModel>[];\n submitLater: IndexDocumentsAction<TModel>[];\n } {\n const hashSet: Set<string> = new Set<string>();\n const resultBatch: IndexDocumentsAction<TModel>[] = [];\n const pruned: IndexDocumentsAction<TModel>[] = [];\n\n for (const document of batch) {\n const key = this.documentKeyRetriever(document as unknown as TModel);\n if (hashSet.has(key)) {\n pruned.push(document);\n } else {\n hashSet.add(key);\n resultBatch.push(document);\n }\n }\n return { batchToSubmit: resultBatch, submitLater: pruned };\n }\n\n private async submitDocuments(\n actionsToSend: IndexDocumentsAction<TModel>[],\n options: OperationOptions,\n retryAttempt: number = 1,\n ): Promise<void> {\n try {\n for (const action of actionsToSend) {\n this.emitter.emit(\"beforeDocumentSent\", action);\n }\n const result = await this.client.indexDocuments(\n new IndexDocumentsBatch<TModel>(actionsToSend),\n options,\n );\n // raise success event\n this.emitter.emit(\"batchSucceeded\", result);\n } catch (e: any) {\n if (e.statusCode && e.statusCode === 413 && actionsToSend.length > 1) {\n // Cut the payload size to half\n const splitActionsArray = [\n actionsToSend.slice(0, actionsToSend.length / 2),\n actionsToSend.slice(actionsToSend.length / 2, actionsToSend.length),\n ];\n this.initialBatchActionCount = splitActionsArray[0].length; // So, we do not want 413 happening again and again\n for (const actions of splitActionsArray) {\n await this.submitDocuments(actions, options);\n }\n } else if (this.isRetryAbleError(e) && retryAttempt <= this.maxRetriesPerAction) {\n // Exponentially increase the delay each time\n const exponentialDelay = this.throttlingDelayInMs * Math.pow(2, retryAttempt);\n // Don't let the delay exceed the maximum\n const clampedExponentialDelay = Math.min(this.maxThrottlingDelayInMs, exponentialDelay);\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n const delayWithJitter =\n clampedExponentialDelay / 2 + getRandomIntegerInclusive(0, clampedExponentialDelay / 2);\n await delay(delayWithJitter);\n await this.submitDocuments(actionsToSend, options, retryAttempt + 1);\n } else {\n this.emitter.emit(\"batchFailed\", e);\n throw e;\n }\n }\n }\n\n private isRetryAbleError(e: any): boolean {\n return e.statusCode && (e.statusCode === 422 || e.statusCode === 409 || e.statusCode === 503);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"searchIndexingBufferedSender.js","sourceRoot":"","sources":["../../src/searchIndexingBufferedSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAa5D,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,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,OAAO,CAAC,CAAC;iBAC9C;aACF;iBAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC/E,6CAA6C;gBAC7C,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;gBAC9E,yCAAyC;gBACzC,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;gBACxF,gFAAgF;gBAChF,mEAAmE;gBACnE,MAAM,eAAe,GACnB,uBAAuB,GAAG,CAAC,GAAG,yBAAyB,CAAC,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,CAAC;gBAC1F,MAAM,KAAK,CAAC,eAAe,CAAC,CAAC;gBAC7B,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;aACtE;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;gBACpC,MAAM,CAAC,CAAC;aACT;SACF;IACH,CAAC;IAEO,gBAAgB,CAAC,CAAM;QAC7B,OAAO,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { IndexDocumentsBatch } from \"./indexDocumentsBatch\";\nimport {\n IndexDocumentsAction,\n IndexDocumentsOptions,\n SearchIndexingBufferedSenderDeleteDocumentsOptions,\n SearchIndexingBufferedSenderFlushDocumentsOptions,\n SearchIndexingBufferedSenderMergeDocumentsOptions,\n SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions,\n SearchIndexingBufferedSenderOptions,\n SearchIndexingBufferedSenderUploadDocumentsOptions,\n} from \"./indexModels\";\nimport { IndexDocumentsResult } from \"./generated/data/models\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport EventEmitter from \"events\";\nimport { createSpan } from \"./tracing\";\nimport { delay } from \"./serviceUtils\";\nimport { getRandomIntegerInclusive } from \"./serviceUtils\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\n/**\n * Index Documents Client\n */\nexport interface IndexDocumentsClient<T extends object> {\n /**\n * Perform a set of index modifications (upload, merge, mergeOrUpload, delete)\n * for the given set of documents.\n *\n * @param batch - An array of actions to perform on the index.\n * @param options - Additional options.\n */\n indexDocuments(\n batch: IndexDocumentsBatch<T>,\n options: IndexDocumentsOptions,\n ): Promise<IndexDocumentsResult>;\n}\n\n/**\n * Default Batch Size\n */\nexport const DEFAULT_BATCH_SIZE: number = 512;\n/**\n * Default window flush interval\n */\nexport const DEFAULT_FLUSH_WINDOW: number = 60000;\n/**\n * Default number of times to retry.\n */\nexport const DEFAULT_RETRY_COUNT: number = 3;\n/**\n * Default retry delay.\n */\nexport const DEFAULT_RETRY_DELAY: number = 800;\n/**\n * Default Max Delay between retries.\n */\nexport const DEFAULT_MAX_RETRY_DELAY: number = 60000;\n\n/**\n * Class used to perform buffered operations against a search index,\n * including adding, updating, and removing them.\n */\nexport class SearchIndexingBufferedSender<TModel extends object> {\n /**\n * Search Client used to call the underlying IndexBatch operations.\n */\n private client: IndexDocumentsClient<TModel>;\n /**\n * Indicates if autoFlush is enabled.\n */\n private autoFlush: boolean;\n /**\n * Interval between flushes (in milliseconds).\n */\n private flushWindowInMs: number;\n /**\n * Delay between retries\n */\n private throttlingDelayInMs: number;\n /**\n * Maximum number of Retries\n */\n private maxRetriesPerAction: number;\n /**\n * Max Delay between retries\n */\n private maxThrottlingDelayInMs: number;\n /**\n * Size of the batch.\n */\n private initialBatchActionCount: number;\n /**\n * Batch object used to complete the service call.\n */\n private batchObject: IndexDocumentsBatch<TModel>;\n /**\n * Clean up for the timer\n */\n private cleanupTimer?: () => void;\n /**\n * Event emitter/publisher used in the Buffered Sender\n */\n private readonly emitter = new EventEmitter();\n /**\n * Method to retrieve the document key\n */\n private documentKeyRetriever: (document: TModel) => string;\n\n /**\n * Creates a new instance of SearchIndexingBufferedSender.\n *\n * @param client - Search Client used to call the underlying IndexBatch operations.\n * @param options - Options to modify auto flush.\n *\n */\n constructor(\n client: IndexDocumentsClient<TModel>,\n documentKeyRetriever: (document: TModel) => string,\n options: SearchIndexingBufferedSenderOptions = {},\n ) {\n this.client = client;\n this.documentKeyRetriever = documentKeyRetriever;\n // General Configuration properties\n this.autoFlush = options.autoFlush ?? true;\n this.initialBatchActionCount = options.initialBatchActionCount ?? DEFAULT_BATCH_SIZE;\n this.flushWindowInMs = options.flushWindowInMs ?? DEFAULT_FLUSH_WINDOW;\n // Retry specific configuration properties\n this.throttlingDelayInMs = options.throttlingDelayInMs ?? DEFAULT_FLUSH_WINDOW;\n this.maxRetriesPerAction = options.maxRetriesPerAction ?? DEFAULT_RETRY_COUNT;\n this.maxThrottlingDelayInMs = options.maxThrottlingDelayInMs ?? DEFAULT_MAX_RETRY_DELAY;\n\n this.batchObject = new IndexDocumentsBatch<TModel>();\n if (this.autoFlush) {\n const interval = setInterval(() => this.flush(), this.flushWindowInMs);\n interval?.unref();\n this.cleanupTimer = () => {\n clearInterval(interval);\n };\n }\n }\n\n /**\n * Uploads the documents/Adds the documents to the upload queue.\n *\n * @param documents - Documents to be uploaded.\n * @param options - Upload options.\n */\n public async uploadDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderUploadDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-uploadDocuments\",\n options,\n );\n try {\n this.batchObject.upload(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"upload\",\n documents,\n });\n return this.internalFlush(false, 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 * Merges the documents/Adds the documents to the merge queue.\n *\n * @param documents - Documents to be merged.\n * @param options - Upload options.\n */\n public async mergeDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderMergeDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-mergeDocuments\",\n options,\n );\n try {\n this.batchObject.merge(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"merge\",\n documents,\n });\n return this.internalFlush(false, 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 * Merges/Uploads the documents/Adds the documents to the merge/upload queue.\n *\n * @param documents - Documents to be merged/uploaded.\n * @param options - Upload options.\n */\n public async mergeOrUploadDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-mergeOrUploadDocuments\",\n options,\n );\n try {\n this.batchObject.mergeOrUpload(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"mergeOrUpload\",\n documents,\n });\n return this.internalFlush(false, 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 * Deletes the documents/Adds the documents to the delete queue.\n *\n * @param documents - Documents to be deleted.\n * @param options - Upload options.\n */\n public async deleteDocuments(\n documents: TModel[],\n options: SearchIndexingBufferedSenderDeleteDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"SearchIndexingBufferedSender-deleteDocuments\",\n options,\n );\n try {\n this.batchObject.delete(documents);\n this.emitter.emit(\"batchAdded\", {\n action: \"delete\",\n documents,\n });\n return this.internalFlush(false, 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 * Flushes the queue manually.\n *\n * @param options - Flush options.\n */\n public async flush(\n options: SearchIndexingBufferedSenderFlushDocumentsOptions = {},\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"SearchIndexingBufferedSender-flush\", options);\n try {\n if (this.batchObject.actions.length > 0) {\n return this.internalFlush(true, 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 * If using autoFlush: true, call this to cleanup the autoflush timer.\n */\n public async dispose(): Promise<void> {\n if (this.batchObject.actions.length > 0) {\n await this.internalFlush(true);\n }\n if (this.cleanupTimer) {\n this.cleanupTimer();\n }\n }\n\n /**\n * Attach Batch Added Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(\n event: \"batchAdded\",\n listener: (e: { action: string; documents: TModel[] }) => void,\n ): void;\n /**\n * Attach Batch Sent Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"beforeDocumentSent\", listener: (e: IndexDocumentsAction<TModel>) => void): void;\n /**\n * Attach Batch Succeeded Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"batchSucceeded\", listener: (e: IndexDocumentsResult) => void): void;\n /**\n * Attach Batch Failed Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public on(event: \"batchFailed\", listener: (e: RestError) => void): void;\n public on(\n event: \"batchAdded\" | \"beforeDocumentSent\" | \"batchSucceeded\" | \"batchFailed\" | \"batchResizing\",\n listener: (e: any) => void,\n ): void {\n this.emitter.on(event, listener);\n }\n\n /**\n * Detach Batch Added Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(\n event: \"batchAdded\",\n listener: (e: { action: string; documents: TModel[] }) => void,\n ): void;\n /**\n * Detach Batch Sent Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(\n event: \"beforeDocumentSent\",\n listener: (e: IndexDocumentsAction<TModel>) => void,\n ): void;\n /**\n * Detach Batch Succeeded Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(event: \"batchSucceeded\", listener: (e: IndexDocumentsResult) => void): void;\n /**\n * Detach Batch Failed Event\n *\n * @param event - Event to be emitted\n * @param listener - Event Listener\n */\n public off(event: \"batchFailed\", listener: (e: RestError) => void): void;\n public off(\n event: \"batchAdded\" | \"beforeDocumentSent\" | \"batchSucceeded\" | \"batchFailed\",\n listener: (e: any) => void,\n ): void {\n this.emitter.removeListener(event, listener);\n }\n\n private isBatchReady(): boolean {\n return this.batchObject.actions.length >= this.initialBatchActionCount;\n }\n\n private async internalFlush(force: boolean, options: OperationOptions = {}): Promise<void> {\n if (force || (this.autoFlush && this.isBatchReady())) {\n // Split it\n const actions: IndexDocumentsAction<TModel>[] = this.batchObject.actions;\n this.batchObject = new IndexDocumentsBatch<TModel>();\n while (actions.length > 0) {\n const actionsToSend = actions.splice(0, this.initialBatchActionCount);\n const { batchToSubmit, submitLater } = this.pruneActions(actionsToSend);\n actions.unshift(...submitLater);\n await this.submitDocuments(batchToSubmit, options);\n }\n }\n }\n\n private pruneActions(batch: IndexDocumentsAction<TModel>[]): {\n batchToSubmit: IndexDocumentsAction<TModel>[];\n submitLater: IndexDocumentsAction<TModel>[];\n } {\n const hashSet: Set<string> = new Set<string>();\n const resultBatch: IndexDocumentsAction<TModel>[] = [];\n const pruned: IndexDocumentsAction<TModel>[] = [];\n\n for (const document of batch) {\n const key = this.documentKeyRetriever(document as unknown as TModel);\n if (hashSet.has(key)) {\n pruned.push(document);\n } else {\n hashSet.add(key);\n resultBatch.push(document);\n }\n }\n return { batchToSubmit: resultBatch, submitLater: pruned };\n }\n\n private async submitDocuments(\n actionsToSend: IndexDocumentsAction<TModel>[],\n options: OperationOptions,\n retryAttempt: number = 1,\n ): Promise<void> {\n try {\n for (const action of actionsToSend) {\n this.emitter.emit(\"beforeDocumentSent\", action);\n }\n const result = await this.client.indexDocuments(\n new IndexDocumentsBatch<TModel>(actionsToSend),\n options,\n );\n // raise success event\n this.emitter.emit(\"batchSucceeded\", result);\n } catch (e: any) {\n if (e.statusCode && e.statusCode === 413 && actionsToSend.length > 1) {\n // Cut the payload size to half\n const splitActionsArray = [\n actionsToSend.slice(0, actionsToSend.length / 2),\n actionsToSend.slice(actionsToSend.length / 2, actionsToSend.length),\n ];\n this.initialBatchActionCount = splitActionsArray[0].length; // So, we do not want 413 happening again and again\n for (const actions of splitActionsArray) {\n await this.submitDocuments(actions, options);\n }\n } else if (this.isRetryAbleError(e) && retryAttempt <= this.maxRetriesPerAction) {\n // Exponentially increase the delay each time\n const exponentialDelay = this.throttlingDelayInMs * Math.pow(2, retryAttempt);\n // Don't let the delay exceed the maximum\n const clampedExponentialDelay = Math.min(this.maxThrottlingDelayInMs, exponentialDelay);\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n const delayWithJitter =\n clampedExponentialDelay / 2 + getRandomIntegerInclusive(0, clampedExponentialDelay / 2);\n await delay(delayWithJitter);\n await this.submitDocuments(actionsToSend, options, retryAttempt + 1);\n } else {\n this.emitter.emit(\"batchFailed\", e);\n throw e;\n }\n }\n }\n\n private isRetryAbleError(e: any): boolean {\n return e.statusCode && (e.statusCode === 422 || e.statusCode === 409 || e.statusCode === 503);\n }\n}\n"]}
|
|
@@ -36,7 +36,7 @@ function walk(start, mapper) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
const mapped = mapper(current.value);
|
|
39
|
-
if (
|
|
39
|
+
if (current?.parent && current.key) {
|
|
40
40
|
current.parent[current.key] = mapped;
|
|
41
41
|
}
|
|
42
42
|
if (typeof mapped === "object" && mapped !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAAA,uCAA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C,IAAI,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,OAAO,CAAC,YAAY,EAAE;QACxB,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE;YAC9C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,IAAI,OAAO,CAAC,iBAAiB,EAAE;QAC7B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport GeographyPoint from \"./geographyPoint\";\n\nconst ISO8601DateRegex = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?Z$/i;\nconst GeoJSONPointTypeName = \"Point\";\nconst WorldGeodeticSystem1984 = \"EPSG:4326\"; // See https://epsg.io/4326\n\nexport function serialize<OutputT>(obj: unknown): OutputT {\n return walk(obj, (value) => {\n const result = serializeSpecialNumbers(value);\n return result;\n });\n}\n\nexport function deserialize<OutputT>(obj: unknown): OutputT {\n return walk(obj, (value) => {\n let result = deserializeSpecialNumbers(value);\n result = deserializeDates(result);\n result = deserializeGeoPoint(result);\n return result;\n });\n}\n\nfunction walk(start: unknown, mapper: (val: any) => any): any {\n // eslint-disable-next-line @typescript-eslint/ban-types\n const seenMarker = new WeakMap<object, boolean>();\n const result = { value: undefined };\n const queue: { value: any; parent: any; key: string }[] = [\n { value: start, parent: result, key: \"value\" },\n ];\n\n while (queue.length) {\n const current = queue.shift()!;\n\n if (typeof current.value === \"object\" && current.value !== null) {\n if (seenMarker.has(current.value)) {\n continue;\n } else {\n seenMarker.set(current.value, true);\n }\n }\n\n const mapped = mapper(current.value);\n if (current?.parent && current.key) {\n current.parent[current.key] = mapped;\n }\n if (typeof mapped === \"object\" && mapped !== null) {\n for (const key of Object.keys(mapped)) {\n queue.push({\n value: mapped[key],\n parent: mapped,\n key,\n });\n }\n }\n }\n\n return result.value;\n}\n\nfunction serializeSpecialNumbers(input: unknown): unknown {\n if (typeof input === \"number\") {\n if (isNaN(input)) {\n return \"NaN\";\n } else if (input === Infinity) {\n return \"INF\";\n } else if (input === -Infinity) {\n return \"-INF\";\n }\n }\n return input;\n}\n\nfunction deserializeSpecialNumbers(input: unknown): unknown {\n if (typeof input === \"string\") {\n if (input === \"NaN\") {\n return NaN;\n } else if (input === \"INF\") {\n return Infinity;\n } else if (input === \"-INF\") {\n return -Infinity;\n }\n }\n return input;\n}\n\nfunction deserializeDates(input: unknown): Date | unknown {\n if (typeof input === \"string\") {\n if (ISO8601DateRegex.test(input)) {\n return new Date(input);\n }\n }\n return input;\n}\n\nfunction deserializeGeoPoint(input: unknown): GeographyPoint | unknown {\n if (isGeoJSONPoint(input)) {\n return new GeographyPoint({ longitude: input.coordinates[0], latitude: input.coordinates[1] });\n }\n\n return input;\n}\n\ninterface GeoJSONPoint {\n type: \"Point\";\n coordinates: [number, number];\n crs: {\n type: \"name\";\n properties: {\n name: \"EPSG:4326\";\n };\n };\n}\n\nfunction isGeoJSONPoint(obj: any): obj is GeoJSONPoint {\n const requiredKeys = [\"type\", \"coordinates\"];\n return isValidObject(obj, {\n requiredKeys,\n propertyValidator: (key) => {\n switch (key) {\n case \"type\":\n return obj.type === GeoJSONPointTypeName;\n break;\n case \"coordinates\":\n return isCoordinateArray(obj.coordinates);\n break;\n case \"crs\":\n return isCrs(obj.crs);\n break;\n default:\n return false;\n }\n },\n });\n}\n\nfunction isCoordinateArray(maybeCoordinates: any): boolean {\n if (!Array.isArray(maybeCoordinates)) {\n return false;\n }\n if (maybeCoordinates.length !== 2) {\n return false;\n }\n if (typeof maybeCoordinates[0] !== \"number\" || typeof maybeCoordinates[1] !== \"number\") {\n return false;\n }\n return true;\n}\n\nfunction isCrs(maybeCrs: any): boolean {\n return isValidObject(maybeCrs, {\n requiredKeys: [\"type\", \"properties\"],\n propertyValidator: (key) => {\n switch (key) {\n case \"type\":\n return maybeCrs.type === \"name\";\n break;\n case \"properties\":\n return isCrsProperties(maybeCrs.properties);\n break;\n default:\n return false;\n }\n },\n });\n}\n\nfunction isCrsProperties(maybeProperties: any): boolean {\n return isValidObject(maybeProperties, {\n requiredKeys: [\"name\"],\n propertyValidator: (key) => {\n if (key === \"name\") {\n return maybeProperties.name === WorldGeodeticSystem1984;\n } else {\n return false;\n }\n },\n });\n}\n\nfunction isValidObject(\n obj: any,\n options: {\n requiredKeys?: string[];\n propertyValidator?: (keyName: string) => boolean;\n } = {},\n): boolean {\n if (typeof obj !== \"object\" || obj === null) {\n return false;\n }\n\n const keys = Object.keys(obj);\n\n if (options.requiredKeys) {\n for (const requiredKey of options.requiredKeys) {\n if (!keys.includes(requiredKey)) {\n return false;\n }\n }\n }\n\n if (options.propertyValidator) {\n for (const key of keys) {\n if (!options.propertyValidator(key)) {\n return false;\n }\n }\n }\n\n return true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,qDAAqD,CAAC;AAC/E,MAAM,oBAAoB,GAAG,OAAO,CAAC;AACrC,MAAM,uBAAuB,GAAG,WAAW,CAAC,CAAC,2BAA2B;AAExE,MAAM,UAAU,SAAS,CAAU,GAAY;IAC7C,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAU,GAAY;IAC/C,O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licensed under the MIT license.\n\nimport GeographyPoint from \"./geographyPoint\";\n\nconst ISO8601DateRegex = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?Z$/i;\nconst GeoJSONPointTypeName = \"Point\";\nconst WorldGeodeticSystem1984 = \"EPSG:4326\"; // See https://epsg.io/4326\n\nexport function serialize<OutputT>(obj: unknown): OutputT {\n return walk(obj, (value) => {\n const result = serializeSpecialNumbers(value);\n return result;\n });\n}\n\nexport function deserialize<OutputT>(obj: unknown): OutputT {\n return walk(obj, (value) => {\n let result = deserializeSpecialNumbers(value);\n result = deserializeDates(result);\n result = deserializeGeoPoint(result);\n return result;\n });\n}\n\nfunction walk(start: unknown, mapper: (val: any) => any): any {\n // eslint-disable-next-line @typescript-eslint/ban-types\n const seenMarker = new WeakMap<object, boolean>();\n const result = { value: undefined };\n const queue: { value: any; parent: any; key: string }[] = [\n { value: start, parent: result, key: \"value\" },\n ];\n\n while (queue.length) {\n const current = queue.shift()!;\n\n if (typeof current.value === \"object\" && current.value !== null) {\n if (seenMarker.has(current.value)) {\n continue;\n } else {\n seenMarker.set(current.value, true);\n }\n }\n\n const mapped = mapper(current.value);\n if (current?.parent && current.key) {\n current.parent[current.key] = mapped;\n }\n if (typeof mapped === \"object\" && mapped !== null) {\n for (const key of Object.keys(mapped)) {\n queue.push({\n value: mapped[key],\n parent: mapped,\n key,\n });\n }\n }\n }\n\n return result.value;\n}\n\nfunction serializeSpecialNumbers(input: unknown): unknown {\n if (typeof input === \"number\") {\n if (isNaN(input)) {\n return \"NaN\";\n } else if (input === Infinity) {\n return \"INF\";\n } else if (input === -Infinity) {\n return \"-INF\";\n }\n }\n return input;\n}\n\nfunction deserializeSpecialNumbers(input: unknown): unknown {\n if (typeof input === \"string\") {\n if (input === \"NaN\") {\n return NaN;\n } else if (input === \"INF\") {\n return Infinity;\n } else if (input === \"-INF\") {\n return -Infinity;\n }\n }\n return input;\n}\n\nfunction deserializeDates(input: unknown): Date | unknown {\n if (typeof input === \"string\") {\n if (ISO8601DateRegex.test(input)) {\n return new Date(input);\n }\n }\n return input;\n}\n\nfunction deserializeGeoPoint(input: unknown): GeographyPoint | unknown {\n if (isGeoJSONPoint(input)) {\n return new GeographyPoint({ longitude: input.coordinates[0], latitude: input.coordinates[1] });\n }\n\n return input;\n}\n\ninterface GeoJSONPoint {\n type: \"Point\";\n coordinates: [number, number];\n crs: {\n type: \"name\";\n properties: {\n name: \"EPSG:4326\";\n };\n };\n}\n\nfunction isGeoJSONPoint(obj: any): obj is GeoJSONPoint {\n const requiredKeys = [\"type\", \"coordinates\"];\n return isValidObject(obj, {\n requiredKeys,\n propertyValidator: (key) => {\n switch (key) {\n case \"type\":\n return obj.type === GeoJSONPointTypeName;\n break;\n case \"coordinates\":\n return isCoordinateArray(obj.coordinates);\n break;\n case \"crs\":\n return isCrs(obj.crs);\n break;\n default:\n return false;\n }\n },\n });\n}\n\nfunction isCoordinateArray(maybeCoordinates: any): boolean {\n if (!Array.isArray(maybeCoordinates)) {\n return false;\n }\n if (maybeCoordinates.length !== 2) {\n return false;\n }\n if (typeof maybeCoordinates[0] !== \"number\" || typeof maybeCoordinates[1] !== \"number\") {\n return false;\n }\n return true;\n}\n\nfunction isCrs(maybeCrs: any): boolean {\n return isValidObject(maybeCrs, {\n requiredKeys: [\"type\", \"properties\"],\n propertyValidator: (key) => {\n switch (key) {\n case \"type\":\n return maybeCrs.type === \"name\";\n break;\n case \"properties\":\n return isCrsProperties(maybeCrs.properties);\n break;\n default:\n return false;\n }\n },\n });\n}\n\nfunction isCrsProperties(maybeProperties: any): boolean {\n return isValidObject(maybeProperties, {\n requiredKeys: [\"name\"],\n propertyValidator: (key) => {\n if (key === \"name\") {\n return maybeProperties.name === WorldGeodeticSystem1984;\n } else {\n return false;\n }\n },\n });\n}\n\nfunction isValidObject(\n obj: any,\n options: {\n requiredKeys?: string[];\n propertyValidator?: (keyName: string) => boolean;\n } = {},\n): boolean {\n if (typeof obj !== \"object\" || obj === null) {\n return false;\n }\n\n const keys = Object.keys(obj);\n\n if (options.requiredKeys) {\n for (const requiredKey of options.requiredKeys) {\n if (!keys.includes(requiredKey)) {\n return false;\n }\n }\n }\n\n if (options.propertyValidator) {\n for (const key of keys) {\n if (!options.propertyValidator(key)) {\n return false;\n }\n }\n }\n\n return true;\n}\n"]}
|