@azure/data-tables 13.1.0-alpha.20220216.2 → 13.1.0-alpha.20220218.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.
@@ -4,6 +4,7 @@ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await, __rest } fr
4
4
  import "@azure/core-paging";
5
5
  import { isNamedKeyCredential, isSASCredential, isTokenCredential, } from "@azure/core-auth";
6
6
  import { STORAGE_SCOPE, TablesLoggingAllowedHeaderNames } from "./utils/constants";
7
+ import { injectSecondaryEndpointHeader, tablesSecondaryEndpointPolicy, } from "./secondaryEndpointPolicy";
7
8
  import { parseXML, stringifyXML } from "@azure/core-xml";
8
9
  import { GeneratedClient } from "./generated/generatedClient";
9
10
  import { getClientParamsFromConnectionString } from "./utils/connectionString";
@@ -36,6 +37,7 @@ export class TableServiceClient {
36
37
  },
37
38
  }), (isTokenCredential(credential) && { credential, credentialScopes: STORAGE_SCOPE }));
38
39
  const client = new GeneratedClient(this.url, internalPipelineOptions);
40
+ client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);
39
41
  if (isNamedKeyCredential(credential)) {
40
42
  client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));
41
43
  }
@@ -51,8 +53,8 @@ export class TableServiceClient {
51
53
  * secondary location endpoint when read-access geo-redundant replication is enabled for the account.
52
54
  * @param options - The options parameters.
53
55
  */
54
- getStatistics(options = {}) {
55
- return tracingClient.withSpan("TableServiceClient.getStatistics", options, (updatedOptions) => this.service.getStatistics(updatedOptions));
56
+ async getStatistics(options = {}) {
57
+ return tracingClient.withSpan("TableServiceClient.getStatistics", options, (updatedOptions) => this.service.getStatistics(injectSecondaryEndpointHeader(updatedOptions)));
56
58
  }
57
59
  /**
58
60
  * Gets the properties of an account's Table service, including properties for Analytics and CORS
@@ -98,7 +100,7 @@ export class TableServiceClient {
98
100
  }
99
101
  catch (e) {
100
102
  if (e.statusCode === 404) {
101
- logger.info("TableServiceClient-deleteTable: Table doesn't exist");
103
+ logger.info("TableServiceClient.deleteTable: Table doesn't exist");
102
104
  }
103
105
  else {
104
106
  throw e;
@@ -1 +1 @@
1
- {"version":3,"file":"TableServiceClient.js","sourceRoot":"","sources":["../../src/TableServiceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,oBAAoB,CAAC;AAe5B,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAgG7B,YACE,GAAW,EACX,mBAI6B,EAC7B,OAAmC;QAEnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,MAAM,UAAU,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QACvF,MAAM,aAAa,GACjB,CAAC,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAA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AO,EAAE,aAAa,EACtB,UAAU,GACX,GAAG,mCAAmC,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAEnE,IAAI,UAAU,EAAE;YACd,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SAC/D;aAAM;YACL,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACnD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport \"@azure/core-paging\";\nimport {\n GetPropertiesResponse,\n GetStatisticsResponse,\n ServiceProperties,\n SetPropertiesOptions,\n SetPropertiesResponse,\n} from \"./generatedModels\";\nimport { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport {\n ListTableItemsOptions,\n TableItem,\n TableQueryOptions,\n TableServiceClientOptions,\n} from \"./models\";\nimport {\n NamedKeyCredential,\n SASCredential,\n TokenCredential,\n isNamedKeyCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport { STORAGE_SCOPE, TablesLoggingAllowedHeaderNames } from \"./utils/constants\";\nimport { Service, Table } from \"./generated\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\nimport { TableItemResultPage } from \"./models\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers\";\nimport { isCredential } from \"./utils/isCredential\";\nimport { logger } from \"./logger\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy\";\nimport { tracingClient } from \"./utils/tracing\";\n\n/**\n * A TableServiceClient represents a Client to the Azure Tables service allowing you\n * to perform operations on the tables and the entities.\n */\nexport class TableServiceClient {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.\n */\n public pipeline: Pipeline;\n private table: Table;\n private service: Service;\n\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - NamedKeyCredential | SASCredential used to authenticate requests. Only Supported for Node\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an account name/key:\n *\n * ```js\n * const { AzureNamedKeyCredential, TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, \"<account key>\");\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * sharedKeyCredential\n * );\n * ```\n */\n constructor(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - SASCredential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using a SAS Token.\n *\n * ```js\n * const { AzureSASCredential, TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const sasCredential = new AzureSASCredential(account, \"<account key>\");\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * sasCredential\n * );\n * ```\n */\n constructor(url: string, credential: SASCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```js\n * cons { DefaultAzureCredential } = require(\"@azure/identity\");\n * const { TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const credential = new DefaultAzureCredential();\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential\n * );\n * ```\n */\n constructor(url: string, credential: TokenCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as\n * \"https://myaccount.table.core.windows.net\". You can append a SAS,\n * such as \"https://myaccount.table.core.windows.net?sasString\".\n * @param options - Options to configure the HTTP pipeline.\n * Example appending a SAS token:\n *\n * ```js\n * const account = \"<storage account name>\";\n * const sasToken = \"<SAS token>\";\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * );\n * ```\n */\n constructor(url: string, options?: TableServiceClientOptions);\n constructor(\n url: string,\n credentialOrOptions?:\n | NamedKeyCredential\n | SASCredential\n | TokenCredential\n | TableServiceClientOptions,\n options?: TableServiceClientOptions\n ) {\n this.url = url;\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n const clientOptions =\n (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n clientOptions.endpoint = clientOptions.endpoint || this.url;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...clientOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n },\n ...(isTokenCredential(credential) && { credential, credentialScopes: STORAGE_SCOPE }),\n };\n const client = new GeneratedClient(this.url, internalPipelineOptions);\n if (isNamedKeyCredential(credential)) {\n client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n client.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n this.pipeline = client.pipeline;\n this.table = client.table;\n this.service = client.service;\n }\n\n /**\n * Retrieves statistics related to replication for the Table service. It is only available on the\n * secondary location endpoint when read-access geo-redundant replication is enabled for the account.\n * @param options - The options parameters.\n */\n public getStatistics(options: OperationOptions = {}): Promise<GetStatisticsResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getStatistics\", options, (updatedOptions) =>\n this.service.getStatistics(updatedOptions)\n );\n }\n\n /**\n * Gets the properties of an account's Table service, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param options - The options parameters.\n */\n public getProperties(options: OperationOptions = {}): Promise<GetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getProperties\", options, (updatedOptions) =>\n this.service.getProperties(updatedOptions)\n );\n }\n\n /**\n * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param properties - The Table Service properties.\n * @param options - The options parameters.\n */\n public setProperties(\n properties: ServiceProperties,\n options: SetPropertiesOptions = {}\n ): Promise<SetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.setProperties\", options, (updatedOptions) =>\n this.service.setProperties(properties, updatedOptions)\n );\n }\n\n /**\n * Creates a new table under the given account.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public createTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.createTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.create({ name }, updatedOptions);\n } catch (e) {\n handleTableAlreadyExists(e, { ...updatedOptions, logger, tableName: name });\n }\n }\n );\n }\n\n /**\n * Operation permanently deletes the specified table.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public deleteTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.deleteTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.delete(name, updatedOptions);\n } catch (e) {\n if (e.statusCode === 404) {\n logger.info(\"TableServiceClient-deleteTable: Table doesn't exist\");\n } else {\n throw e;\n }\n }\n }\n );\n }\n\n /**\n * Queries tables under the given account.\n * @param options - The options parameters.\n */\n public listTables(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ListTableItemsOptions\n ): PagedAsyncIterableIterator<TableItem, TableItemResultPage> {\n const iter = this.listTablesAll(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTablesOptions = {\n ...options,\n queryOptions: { top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listTablesPage(pageOptions);\n },\n };\n }\n\n private async *listTablesAll(\n options?: InternalListTablesOptions\n ): AsyncIterableIterator<TableItem> {\n const firstPage = await this._listTables(options);\n const { continuationToken } = firstPage;\n yield* firstPage;\n if (continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken,\n };\n for await (const page of this.listTablesPage(optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listTablesPage(\n options: InternalListTablesOptions = {}\n ): AsyncIterableIterator<TableItemResultPage> {\n let result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n options,\n (updatedOptions) => this._listTables(updatedOptions)\n );\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken: result.continuationToken,\n };\n result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n optionsWithContinuation,\n async (updatedOptions, span) => {\n span.setAttribute(\"continuationToken\", updatedOptions.continuationToken);\n return this._listTables(updatedOptions);\n }\n );\n yield result;\n }\n }\n\n private async _listTables(options: InternalListTablesOptions = {}): Promise<TableItemResultPage> {\n const { continuationToken: nextTableName, ...listOptions } = options;\n const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query({\n ...listOptions,\n nextTableName,\n });\n return Object.assign([...value], { continuationToken });\n }\n\n /**\n *\n * Creates an instance of TableServiceClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Options to configure the HTTP pipeline.\n * @returns A new TableServiceClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableServiceClientOptions\n ): TableServiceClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n\n if (credential) {\n return new TableServiceClient(url, credential, clientOptions);\n } else {\n return new TableServiceClient(url, clientOptions);\n }\n }\n}\n\ntype InternalListTablesOptions = ListTableItemsOptions & {\n queryOptions?: TableQueryOptions & { top?: number };\n /**\n * A table query continuation token from a previous call.\n */\n continuationToken?: string;\n};\n"]}
1
+ {"version":3,"file":"TableServiceClient.js","sourceRoot":"","sources":["../../src/TableServiceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,oBAAoB,CAAC;AAgB5B,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC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Y,CAAC,mBAAmB,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;oBACzE,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBAC1C,CAAC,CACF,CAAA,CAAC;gBACF,oBAAM,MAAM,CAAA,CAAC;aACd;QACH,CAAC;KAAA;IAEO,KAAK,CAAC,WAAW,CAAC,UAAqC,EAAE;QAC/D,MAAM,EAAE,iBAAiB,EAAE,aAAa,KAAqB,OAAO,EAAvB,WAAW,UAAK,OAAO,EAA9D,qBAAoD,CAAU,CAAC;QACrE,MAAM,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,iCACzF,WAAW,KACd,aAAa,IACb,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,oBAAoB,CAChC,gBAAwB;IACxB,8DAA8D;IAC9D,OAAmC;QAEnC,MAAM,EACJ,GAAG,EACH,OAAO,EAAE,aAAa,EACtB,UAAU,GACX,GAAG,mCAAmC,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAEnE,IAAI,UAAU,EAAE;YACd,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SAC/D;aAAM;YACL,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACnD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport \"@azure/core-paging\";\n\nimport {\n GetPropertiesResponse,\n GetStatisticsResponse,\n ServiceProperties,\n SetPropertiesOptions,\n SetPropertiesResponse,\n} from \"./generatedModels\";\nimport { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport {\n ListTableItemsOptions,\n TableItem,\n TableQueryOptions,\n TableServiceClientOptions,\n} from \"./models\";\nimport {\n NamedKeyCredential,\n SASCredential,\n TokenCredential,\n isNamedKeyCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport { STORAGE_SCOPE, TablesLoggingAllowedHeaderNames } from \"./utils/constants\";\nimport { Service, Table } from \"./generated\";\nimport {\n injectSecondaryEndpointHeader,\n tablesSecondaryEndpointPolicy,\n} from \"./secondaryEndpointPolicy\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\n\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\nimport { TableItemResultPage } from \"./models\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers\";\nimport { isCredential } from \"./utils/isCredential\";\nimport { logger } from \"./logger\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy\";\nimport { tracingClient } from \"./utils/tracing\";\n\n/**\n * A TableServiceClient represents a Client to the Azure Tables service allowing you\n * to perform operations on the tables and the entities.\n */\nexport class TableServiceClient {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.\n */\n public pipeline: Pipeline;\n private table: Table;\n private service: Service;\n\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - NamedKeyCredential | SASCredential used to authenticate requests. Only Supported for Node\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an account name/key:\n *\n * ```js\n * const { AzureNamedKeyCredential, TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, \"<account key>\");\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * sharedKeyCredential\n * );\n * ```\n */\n constructor(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - SASCredential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using a SAS Token.\n *\n * ```js\n * const { AzureSASCredential, TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const sasCredential = new AzureSASCredential(account, \"<account key>\");\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * sasCredential\n * );\n * ```\n */\n constructor(url: string, credential: SASCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```js\n * cons { DefaultAzureCredential } = require(\"@azure/identity\");\n * const { TableServiceClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\"\n * const credential = new DefaultAzureCredential();\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential\n * );\n * ```\n */\n constructor(url: string, credential: TokenCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as\n * \"https://myaccount.table.core.windows.net\". You can append a SAS,\n * such as \"https://myaccount.table.core.windows.net?sasString\".\n * @param options - Options to configure the HTTP pipeline.\n * Example appending a SAS token:\n *\n * ```js\n * const account = \"<storage account name>\";\n * const sasToken = \"<SAS token>\";\n *\n * const tableServiceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * );\n * ```\n */\n constructor(url: string, options?: TableServiceClientOptions);\n constructor(\n url: string,\n credentialOrOptions?:\n | NamedKeyCredential\n | SASCredential\n | TokenCredential\n | TableServiceClientOptions,\n options?: TableServiceClientOptions\n ) {\n this.url = url;\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n const clientOptions =\n (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n clientOptions.endpoint = clientOptions.endpoint || this.url;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...clientOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n },\n ...(isTokenCredential(credential) && { credential, credentialScopes: STORAGE_SCOPE }),\n };\n const client = new GeneratedClient(this.url, internalPipelineOptions);\n client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);\n\n if (isNamedKeyCredential(credential)) {\n client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n client.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n this.pipeline = client.pipeline;\n this.table = client.table;\n this.service = client.service;\n }\n\n /**\n * Retrieves statistics related to replication for the Table service. It is only available on the\n * secondary location endpoint when read-access geo-redundant replication is enabled for the account.\n * @param options - The options parameters.\n */\n public async getStatistics(options: OperationOptions = {}): Promise<GetStatisticsResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getStatistics\", options, (updatedOptions) =>\n this.service.getStatistics(injectSecondaryEndpointHeader(updatedOptions))\n );\n }\n\n /**\n * Gets the properties of an account's Table service, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param options - The options parameters.\n */\n public getProperties(options: OperationOptions = {}): Promise<GetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getProperties\", options, (updatedOptions) =>\n this.service.getProperties(updatedOptions)\n );\n }\n\n /**\n * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param properties - The Table Service properties.\n * @param options - The options parameters.\n */\n public setProperties(\n properties: ServiceProperties,\n options: SetPropertiesOptions = {}\n ): Promise<SetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.setProperties\", options, (updatedOptions) =>\n this.service.setProperties(properties, updatedOptions)\n );\n }\n\n /**\n * Creates a new table under the given account.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public createTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.createTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.create({ name }, updatedOptions);\n } catch (e) {\n handleTableAlreadyExists(e, { ...updatedOptions, logger, tableName: name });\n }\n }\n );\n }\n\n /**\n * Operation permanently deletes the specified table.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public deleteTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.deleteTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.delete(name, updatedOptions);\n } catch (e) {\n if (e.statusCode === 404) {\n logger.info(\"TableServiceClient.deleteTable: Table doesn't exist\");\n } else {\n throw e;\n }\n }\n }\n );\n }\n\n /**\n * Queries tables under the given account.\n * @param options - The options parameters.\n */\n public listTables(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ListTableItemsOptions\n ): PagedAsyncIterableIterator<TableItem, TableItemResultPage> {\n const iter = this.listTablesAll(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTablesOptions = {\n ...options,\n queryOptions: { top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listTablesPage(pageOptions);\n },\n };\n }\n\n private async *listTablesAll(\n options?: InternalListTablesOptions\n ): AsyncIterableIterator<TableItem> {\n const firstPage = await this._listTables(options);\n const { continuationToken } = firstPage;\n yield* firstPage;\n if (continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken,\n };\n for await (const page of this.listTablesPage(optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listTablesPage(\n options: InternalListTablesOptions = {}\n ): AsyncIterableIterator<TableItemResultPage> {\n let result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n options,\n (updatedOptions) => this._listTables(updatedOptions)\n );\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken: result.continuationToken,\n };\n result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n optionsWithContinuation,\n async (updatedOptions, span) => {\n span.setAttribute(\"continuationToken\", updatedOptions.continuationToken);\n return this._listTables(updatedOptions);\n }\n );\n yield result;\n }\n }\n\n private async _listTables(options: InternalListTablesOptions = {}): Promise<TableItemResultPage> {\n const { continuationToken: nextTableName, ...listOptions } = options;\n const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query({\n ...listOptions,\n nextTableName,\n });\n return Object.assign([...value], { continuationToken });\n }\n\n /**\n *\n * Creates an instance of TableServiceClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Options to configure the HTTP pipeline.\n * @returns A new TableServiceClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableServiceClientOptions\n ): TableServiceClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n\n if (credential) {\n return new TableServiceClient(url, credential, clientOptions);\n } else {\n return new TableServiceClient(url, clientOptions);\n }\n }\n}\n\ntype InternalListTablesOptions = ListTableItemsOptions & {\n queryOptions?: TableQueryOptions & { top?: number };\n /**\n * A table query continuation token from a previous call.\n */\n continuationToken?: string;\n};\n"]}
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ /**
4
+ * The programmatic identifier of the tablesSecondaryEndpointPolicy.
5
+ */
6
+ export const tablesSecondaryEndpointPolicyName = "tablesSecondaryEndpointPolicy";
7
+ export const SecondaryLocationHeaderName = "tables-secondary-endpoint";
8
+ const SecondaryLocationAccountSuffix = "-secondary";
9
+ /**
10
+ * Policy that would replace the Primary Endpoint with the secondary endpoint
11
+ * when the `tables-secondary-endpoint` is set in the request
12
+ */
13
+ export const tablesSecondaryEndpointPolicy = {
14
+ name: tablesSecondaryEndpointPolicyName,
15
+ sendRequest: async (req, next) => {
16
+ // Only replace the URL if the SecondaryLocationHeader is set
17
+ if (req.headers.get(SecondaryLocationHeaderName)) {
18
+ // Since the header is for internal use only, clean it up.
19
+ req.headers.delete(SecondaryLocationHeaderName);
20
+ // Calculate and update the secondary url
21
+ req.url = getSecondaryUrlFromPrimary(req.url);
22
+ }
23
+ return next(req);
24
+ },
25
+ };
26
+ /**
27
+ * Utility function that injects the SecondaryEndpointHeader into an operation options
28
+ */
29
+ export function injectSecondaryEndpointHeader(options) {
30
+ var _a;
31
+ const headerToInject = { [SecondaryLocationHeaderName]: "true" };
32
+ return Object.assign(Object.assign({}, options), { requestOptions: Object.assign(Object.assign({}, options.requestOptions), { customHeaders: Object.assign(Object.assign({}, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.customHeaders), headerToInject) }) });
33
+ }
34
+ /**
35
+ * Utility function that calculates the secondary URL for a table instance given the primary URL.
36
+ */
37
+ function getSecondaryUrlFromPrimary(primaryUrl) {
38
+ const parsedPrimaryUrl = new URL(primaryUrl);
39
+ const host = parsedPrimaryUrl.hostname.split(".");
40
+ if (host.length > 1) {
41
+ host[0] = `${host[0]}${SecondaryLocationAccountSuffix}`;
42
+ }
43
+ parsedPrimaryUrl.hostname = host.join(".");
44
+ return parsedPrimaryUrl.toString();
45
+ }
46
+ //# sourceMappingURL=secondaryEndpointPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondaryEndpointPolicy.js","sourceRoot":"","sources":["../../src/secondaryEndpointPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC;AACjF,MAAM,CAAC,MAAM,2BAA2B,GAAG,2BAA2B,CAAC;AACvE,MAAM,8BAA8B,GAAG,YAAY,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAmB;IAC3D,IAAI,EAAE,iCAAiC;IACvC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC/B,6DAA6D;QAC7D,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,EAAE;YAChD,0DAA0D;YAC1D,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;YAChD,yCAAyC;YACzC,GAAG,CAAC,GAAG,GAAG,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC/C;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAyB;;IACrE,MAAM,cAAc,GAAG,EAAE,CAAC,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACjE,uCACK,OAAO,KACV,cAAc,kCACT,OAAO,CAAC,cAAc,KACzB,aAAa,kCACR,MAAA,OAAO,CAAC,cAAc,0CAAE,aAAa,GACrC,cAAc,QAGrB;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAAC,UAAkB;IACpD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACnB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,8BAA8B,EAAE,CAAC;KACzD;IACD,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE3C,OAAO,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AACrC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the tablesSecondaryEndpointPolicy.\n */\nexport const tablesSecondaryEndpointPolicyName = \"tablesSecondaryEndpointPolicy\";\nexport const SecondaryLocationHeaderName = \"tables-secondary-endpoint\";\nconst SecondaryLocationAccountSuffix = \"-secondary\";\n\n/**\n * Policy that would replace the Primary Endpoint with the secondary endpoint\n * when the `tables-secondary-endpoint` is set in the request\n */\nexport const tablesSecondaryEndpointPolicy: PipelinePolicy = {\n name: tablesSecondaryEndpointPolicyName,\n sendRequest: async (req, next) => {\n // Only replace the URL if the SecondaryLocationHeader is set\n if (req.headers.get(SecondaryLocationHeaderName)) {\n // Since the header is for internal use only, clean it up.\n req.headers.delete(SecondaryLocationHeaderName);\n // Calculate and update the secondary url\n req.url = getSecondaryUrlFromPrimary(req.url);\n }\n\n return next(req);\n },\n};\n\n/**\n * Utility function that injects the SecondaryEndpointHeader into an operation options\n */\nexport function injectSecondaryEndpointHeader(options: OperationOptions): OperationOptions {\n const headerToInject = { [SecondaryLocationHeaderName]: \"true\" };\n return {\n ...options,\n requestOptions: {\n ...options.requestOptions,\n customHeaders: {\n ...options.requestOptions?.customHeaders,\n ...headerToInject,\n },\n },\n };\n}\n\n/**\n * Utility function that calculates the secondary URL for a table instance given the primary URL.\n */\nfunction getSecondaryUrlFromPrimary(primaryUrl: string): string {\n const parsedPrimaryUrl = new URL(primaryUrl);\n const host = parsedPrimaryUrl.hostname.split(\".\");\n if (host.length > 1) {\n host[0] = `${host[0]}${SecondaryLocationAccountSuffix}`;\n }\n parsedPrimaryUrl.hostname = host.join(\".\");\n\n return parsedPrimaryUrl.toString();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEpG,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/E,gBAAgB,GAAG,2BAA2B,CAAC;QAC/C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;KACxC;IACD,MAAM,cAAc,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IACtE,IAAI,cAAc,CAAC,IAAI,KAAK,mBAAmB,EAAE;QAC/C,OAAO,2BAA2B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;KAC7D;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,eAAe,EAA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C,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\nimport { TableServiceClientOptions } from \"../models\";\nimport { URL } from \"./url\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {}\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options,\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\"\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\"\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
1
+ {"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAGpG,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB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uCAAuC;QACvC,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAClC;SAAM,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QAChC,iFAAiF;QACjF,2GAA2G;QAC3G,mCAAmC;QACnC,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\n\nimport { TableServiceClientOptions } from \"../models\";\nimport { URL } from \"./url\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {}\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options,\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\"\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\"\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/data-tables",
3
- "version": "13.1.0-alpha.20220216.2",
3
+ "version": "13.1.0-alpha.20220218.1",
4
4
  "description": "An isomorphic client library for the Azure Tables service.",
5
5
  "sdk-type": "client",
6
6
  "main": "dist/index.js",