@azure/data-tables 13.0.2-alpha.20220118.1 → 13.0.2-alpha.20220214.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 +41 -38
- package/dist/index.js.map +1 -1
- package/dist-esm/src/TableClient.js +2 -1
- package/dist-esm/src/TableClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js +4 -22
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/package.json +11 -21
- package/types/3.1/data-tables.d.ts +1 -0
- package/types/latest/data-tables.d.ts +1 -0
|
@@ -56,6 +56,7 @@ export class TableClient {
|
|
|
56
56
|
if (isCosmosEndpoint(this.url)) {
|
|
57
57
|
generatedClient.pipeline.addPolicy(cosmosPatchPolicy());
|
|
58
58
|
}
|
|
59
|
+
this.generatedClient = generatedClient;
|
|
59
60
|
this.table = generatedClient.table;
|
|
60
61
|
this.pipeline = generatedClient.pipeline;
|
|
61
62
|
}
|
|
@@ -592,7 +593,7 @@ export class TableClient {
|
|
|
592
593
|
const changesetId = Uuid.generateUuid();
|
|
593
594
|
if (!this.transactionClient) {
|
|
594
595
|
// Add pipeline
|
|
595
|
-
this.transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.
|
|
596
|
+
this.transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.generatedClient, new TableClient(this.url, this.tableName), this.credential, this.allowInsecureConnection);
|
|
596
597
|
}
|
|
597
598
|
else {
|
|
598
599
|
this.transactionClient.reset(transactionId, changesetId, partitionKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableClient.js","sourceRoot":"","sources":["../../src/TableClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,oBAAoB,CAAC;AA8B5B,OAAO,EAAE,eAAe,EAAmC,MAAM,aAAa,CAAC;AAC/E,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,iBAAiB,G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,GAAG,mCAAmC,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACnE,IAAI,UAAU,EAAE;YACd,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;SACvD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport \"@azure/core-paging\";\nimport {\n CreateTableEntityResponse,\n DeleteTableEntityOptions,\n GetAccessPolicyResponse,\n GetTableEntityOptions,\n GetTableEntityResponse,\n ListTableEntitiesOptions,\n SignedIdentifier,\n TableServiceClientOptions as TableClientOptions,\n TableEntity,\n TableEntityQueryOptions,\n TableEntityResult,\n TableEntityResultPage,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n} from \"./models\";\nimport {\n DeleteTableEntityResponse,\n SetAccessPolicyResponse,\n UpdateEntityResponse,\n UpsertEntityResponse,\n} from \"./generatedModels\";\nimport {\n FullOperationResponse,\n InternalClientPipelineOptions,\n OperationOptions,\n} from \"@azure/core-client\";\nimport { GeneratedClient, TableDeleteEntityOptionalParams } from \"./generated\";\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 { decodeContinuationToken, encodeContinuationToken } from \"./utils/continuationToken\";\nimport {\n deserialize,\n deserializeObjectsArray,\n deserializeSignedIdentifier,\n serialize,\n serializeQueryOptions,\n serializeSignedIdentifiers,\n} from \"./serialization\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { InternalTableTransaction } from \"./TableTransaction\";\nimport { ListEntitiesResponse } from \"./utils/internalModels\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { Table } from \"./generated/operationsInterfaces\";\nimport { TableQueryEntitiesOptionalParams } from \"./generated/models\";\nimport { Uuid } from \"./utils/uuid\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy\";\nimport { createSpan } from \"./utils/tracing\";\nimport { escapeQuotes } from \"./odata\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint\";\nimport { isCredential } from \"./utils/isCredential\";\nimport { logger } from \"./logger\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy\";\n\n/**\n * A TableClient represents a Client to the Azure Tables service allowing you\n * to perform operations on a single table.\n */\nexport class TableClient {\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 credential?: NamedKeyCredential | SASCredential | TokenCredential;\n private transactionClient?: InternalTableTransaction;\n private clientOptions: TableClientOptions;\n private readonly allowInsecureConnection: boolean;\n\n /**\n * Name of the table to perform operations on.\n */\n public readonly tableName: string;\n\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - NamedKeyCredential used to authenticate requests. Only Supported for Node\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using an account name/key:\n *\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * sharedKeyCredential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: NamedKeyCredential,\n options?: TableClientOptions\n );\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - SASCredential used to authenticate requests\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using a SAS Token:\n *\n * ```js\n * const { AzureSASCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<sas-token>\";\n * const tableName = \"<table name>\";\n * const sasCredential = new AzureSASCredential(sasToken);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * sasCredential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: SASCredential,\n options?: TableClientOptions\n );\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```js\n * cons { DefaultAzureCredential } = require(\"@azure/identity\");\n * const { AzureSASCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<sas-token>\";\n * const tableName = \"<table name>\";\n * const credential = new DefaultAzureCredential();\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * credential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: TokenCredential,\n options?: TableClientOptions\n );\n /**\n * Creates an instance of TableClient.\n *\n * @param url - A Client string pointing to Azure Storage table service, 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 tableName - the name of the table\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example appending a SAS token:\n *\n * ```js\n * const { TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<SAS token>\";\n * const tableName = \"<table name>\";\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * `${tableName}`\n * );\n * ```\n */\n constructor(url: string, tableName: string, options?: TableClientOptions);\n constructor(\n url: string,\n tableName: string,\n credentialOrOptions?: NamedKeyCredential | SASCredential | TableClientOptions | TokenCredential,\n options: TableClientOptions = {}\n ) {\n this.url = url;\n this.tableName = tableName;\n\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n this.credential = credential;\n\n this.clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n this.allowInsecureConnection = this.clientOptions.allowInsecureConnection ?? false;\n this.clientOptions.endpoint = this.clientOptions.endpoint || this.url;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...this.clientOptions,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n ...(isTokenCredential(this.credential) && {\n credential: this.credential,\n credentialScopes: STORAGE_SCOPE,\n }),\n };\n\n const generatedClient = new GeneratedClient(this.url, internalPipelineOptions);\n if (isNamedKeyCredential(credential)) {\n generatedClient.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n generatedClient.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n if (isCosmosEndpoint(this.url)) {\n generatedClient.pipeline.addPolicy(cosmosPatchPolicy());\n }\n\n this.table = generatedClient.table;\n this.pipeline = generatedClient.pipeline;\n }\n\n /**\n * Permanently deletes the current table with all of its entities.\n * @param options - The options parameters.\n *\n * ### Example deleting a table\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // calling deleteTable will delete the table used\n * // to instantiate the TableClient.\n * // Note: If the table doesn't exist this function doesn't fail.\n * await client.deleteTable();\n * ```\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async deleteTable(options: OperationOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"TableClient-deleteTable\", options);\n try {\n await this.table.delete(this.tableName, updatedOptions);\n } catch (e) {\n if (e.statusCode === 404) {\n logger.info(\"TableClient-deleteTable: Table doesn't exist\");\n } else {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n }\n } finally {\n span.end();\n }\n }\n\n /**\n * Creates a table with the tableName passed to the client constructor\n * @param options - The options parameters.\n *\n * ### Example creating a table\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // calling create table will create the table used\n * // to instantiate the TableClient.\n * // Note: If the table already\n * // exists this function doesn't throw.\n * await client.createTable();\n * ```\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async createTable(options: OperationOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"TableClient-createTable\", options);\n try {\n await this.table.create({ name: this.tableName }, updatedOptions);\n } catch (e) {\n handleTableAlreadyExists(e, { ...updatedOptions, span, logger, tableName: this.tableName });\n } finally {\n span.end();\n }\n }\n\n /**\n * Returns a single entity in the table.\n * @param partitionKey - The partition key of the entity.\n * @param rowKey - The row key of the entity.\n * @param options - The options parameters.\n *\n * ### Example getting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // getEntity will get a single entity stored in the service that\n * // matches exactly the partitionKey and rowKey used as parameters\n * // to the method.\n * const entity = await client.getEntity(\"<partitionKey>\", \"<rowKey>\");\n * console.log(entity);\n * ```\n */\n public async getEntity<T extends object = Record<string, unknown>>(\n partitionKey: string,\n rowKey: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: GetTableEntityOptions = {}\n ): Promise<GetTableEntityResponse<TableEntityResult<T>>> {\n const { span, updatedOptions } = createSpan(\"TableClient-getEntity\", options);\n\n let parsedBody: any;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n parsedBody = rawResponse.parsedBody;\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n }\n\n try {\n const { disableTypeConversion, queryOptions, ...getEntityOptions } = updatedOptions || {};\n await this.table.queryEntitiesWithPartitionAndRowKey(\n this.tableName,\n escapeQuotes(partitionKey),\n escapeQuotes(rowKey),\n {\n ...getEntityOptions,\n queryOptions: serializeQueryOptions(queryOptions || {}),\n onResponse,\n }\n );\n const tableEntity = deserialize<TableEntityResult<T>>(\n parsedBody,\n disableTypeConversion ?? false\n );\n\n return tableEntity;\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Queries entities in a table.\n * @param options - The options parameters.\n *\n * Example listing entities\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // list entities returns a AsyncIterableIterator\n * // this helps consuming paginated responses by\n * // automatically handling getting the next pages\n * const entities = client.listEntities();\n *\n * // this loop will get all the entities from all the pages\n * // returned by the service\n * for await (const entity of entities) {\n * console.log(entity);\n * }\n * ```\n */\n public listEntities<T extends object = Record<string, unknown>>(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: ListTableEntitiesOptions = {}\n ): PagedAsyncIterableIterator<TableEntityResult<T>, TableEntityResultPage<T>> {\n const tableName = this.tableName;\n const iter = this.listEntitiesAll<T>(tableName, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTableEntitiesOptions = {\n ...options,\n queryOptions: { ...options.queryOptions, top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listEntitiesPage(tableName, pageOptions);\n },\n };\n }\n\n private async *listEntitiesAll<T extends object>(\n tableName: string,\n options?: InternalListTableEntitiesOptions\n ): AsyncIterableIterator<TableEntityResult<T>> {\n const firstPage = await this._listEntities<T>(tableName, options);\n yield* firstPage;\n if (firstPage.continuationToken) {\n const optionsWithContinuation: InternalListTableEntitiesOptions = {\n ...options,\n continuationToken: firstPage.continuationToken,\n };\n for await (const page of this.listEntitiesPage<T>(tableName, optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listEntitiesPage<T extends object>(\n tableName: string,\n options: InternalListTableEntitiesOptions = {}\n ): AsyncIterableIterator<ListEntitiesResponse<TableEntityResult<T>>> {\n const { span, updatedOptions } = createSpan(\"TableClient-listEntitiesPage\", options);\n\n try {\n let result = await this._listEntities<T>(tableName, updatedOptions);\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTableEntitiesOptions = {\n ...updatedOptions,\n continuationToken: result.continuationToken,\n };\n\n result = await this._listEntities(tableName, optionsWithContinuation);\n\n yield result;\n }\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async _listEntities<T extends object>(\n tableName: string,\n options: InternalListTableEntitiesOptions = {}\n ): Promise<TableEntityResultPage<T>> {\n const { disableTypeConversion = false } = options;\n const queryOptions = serializeQueryOptions(options.queryOptions || {});\n const listEntitiesOptions: TableQueryEntitiesOptionalParams = {\n ...options,\n queryOptions,\n };\n\n // If a continuation token is used, decode it and set the next row and partition key\n if (options.continuationToken) {\n const continuationToken = decodeContinuationToken(options.continuationToken);\n listEntitiesOptions.nextRowKey = continuationToken.nextRowKey;\n listEntitiesOptions.nextPartitionKey = continuationToken.nextPartitionKey;\n }\n\n const {\n xMsContinuationNextPartitionKey: nextPartitionKey,\n xMsContinuationNextRowKey: nextRowKey,\n value,\n } = await this.table.queryEntities(tableName, listEntitiesOptions);\n\n const tableEntities = deserializeObjectsArray<TableEntityResult<T>>(\n value ?? [],\n disableTypeConversion\n );\n\n // Encode nextPartitionKey and nextRowKey as a single continuation token and add it as a\n // property to the page.\n const continuationToken = encodeContinuationToken(nextPartitionKey, nextRowKey);\n const page: TableEntityResultPage<T> = Object.assign([...tableEntities], {\n continuationToken,\n });\n\n return page;\n }\n\n /**\n * Insert entity in the table.\n * @param entity - The properties for the table entity.\n * @param options - The options parameters.\n *\n * ### Example creating an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // partitionKey and rowKey are required properties of the entity to create\n * // and accepts any other properties\n * await client.createEntity({partitionKey: \"p1\", rowKey: \"r1\", foo: \"Hello!\"});\n * ```\n */\n public async createEntity<T extends object>(\n entity: TableEntity<T>,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {}\n ): Promise<CreateTableEntityResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-createEntity\", options);\n\n try {\n const { ...createTableEntity } = updatedOptions || {};\n return await this.table.insertEntity(this.tableName, {\n ...createTableEntity,\n tableEntityProperties: serialize(entity),\n responsePreference: \"return-no-content\",\n });\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Deletes the specified entity in the table.\n * @param partitionKey - The partition key of the entity.\n * @param rowKey - The row key of the entity.\n * @param options - The options parameters.\n *\n * ### Example deleting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // deleteEntity deletes the entity that matches\n * // exactly the partitionKey and rowKey passed as parameters\n * await client.deleteEntity(\"<partitionKey>\", \"<rowKey>\")\n * ```\n */\n public async deleteEntity(\n partitionKey: string,\n rowKey: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: DeleteTableEntityOptions = {}\n ): Promise<DeleteTableEntityResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-deleteEntity\", options);\n\n try {\n const { etag = \"*\", ...rest } = updatedOptions || {};\n const deleteOptions: TableDeleteEntityOptionalParams = {\n ...rest,\n };\n return await this.table.deleteEntity(\n this.tableName,\n escapeQuotes(partitionKey),\n escapeQuotes(rowKey),\n etag,\n deleteOptions\n );\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update an entity in the table.\n * @param entity - The properties of the entity to be updated.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n *\n * ### Example updating an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * const entity = {partitionKey: \"p1\", rowKey: \"r1\", bar: \"updatedBar\"};\n *\n * // Update uses update mode \"Merge\" as default\n * // merge means that update will match a stored entity\n * // that has the same partitionKey and rowKey as the entity\n * // passed to the method and then will only update the properties present in it.\n * // Any other properties that are not defined in the entity passed to updateEntity\n * // will remain as they are in the service\n * await client.updateEntity(entity)\n *\n * // We can also set the update mode to Replace, which will match the entity passed\n * // to updateEntity with one stored in the service and replace with the new one.\n * // If there are any missing properties in the entity passed to updateEntity, they\n * // will be removed from the entity stored in the service\n * await client.updateEntity(entity, \"Replace\")\n * ```\n */\n public async updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode = \"Merge\",\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: UpdateTableEntityOptions = {}\n ): Promise<UpdateEntityResponse> {\n const { span, updatedOptions } = createSpan(`TableClient-updateEntity-${mode}`, options);\n\n try {\n const partitionKey = escapeQuotes(entity.partitionKey);\n const rowKey = escapeQuotes(entity.rowKey);\n\n const { etag = \"*\", ...updateEntityOptions } = updatedOptions || {};\n if (mode === \"Merge\") {\n return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ifMatch: etag,\n ...updateEntityOptions,\n });\n }\n if (mode === \"Replace\") {\n return await this.table.updateEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ifMatch: etag,\n ...updateEntityOptions,\n });\n }\n\n throw new Error(`Unexpected value for update mode: ${mode}`);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Upsert an entity in the table.\n * @param entity - The properties for the table entity.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n *\n * ### Example upserting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * const entity = {partitionKey: \"p1\", rowKey: \"r1\", bar: \"updatedBar\"};\n *\n * // Upsert uses update mode \"Merge\" as default.\n * // This behaves similarly to update but creates the entity\n * // if it doesn't exist in the service\n * await client.upsertEntity(entity)\n *\n * // We can also set the update mode to Replace.\n * // This behaves similarly to update but creates the entity\n * // if it doesn't exist in the service\n * await client.upsertEntity(entity, \"Replace\")\n * ```\n */\n public async upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode = \"Merge\",\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {}\n ): Promise<UpsertEntityResponse> {\n const { span, updatedOptions } = createSpan(`TableClient-upsertEntity-${mode}`, options);\n\n try {\n const partitionKey = escapeQuotes(entity.partitionKey);\n const rowKey = escapeQuotes(entity.rowKey);\n\n if (mode === \"Merge\") {\n return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ...updatedOptions,\n });\n }\n\n if (mode === \"Replace\") {\n return await this.table.updateEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ...updatedOptions,\n });\n }\n throw new Error(`Unexpected value for update mode: ${mode}`);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Retrieves details about any stored access policies specified on the table that may be used with\n * Shared Access Signatures.\n * @param options - The options parameters.\n */\n public async getAccessPolicy(options: OperationOptions = {}): Promise<GetAccessPolicyResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-getAccessPolicy\", options);\n try {\n const signedIdentifiers = await this.table.getAccessPolicy(this.tableName, updatedOptions);\n return deserializeSignedIdentifier(signedIdentifiers);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Sets stored access policies for the table that may be used with Shared Access Signatures.\n * @param tableAcl - The Access Control List for the table.\n * @param options - The options parameters.\n */\n public async setAccessPolicy(\n tableAcl: SignedIdentifier[],\n options: OperationOptions = {}\n ): Promise<SetAccessPolicyResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-setAccessPolicy\", options);\n try {\n const serlializedAcl = serializeSignedIdentifiers(tableAcl);\n return await this.table.setAccessPolicy(this.tableName, {\n ...updatedOptions,\n tableAcl: serlializedAcl,\n });\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Submits a Transaction which is composed of a set of actions. You can provide the actions as a list\n * or you can use {@link TableTransaction} to help building the transaction.\n *\n * Example usage:\n * ```typescript\n * const { TableClient } = require(\"@azure/data-tables\");\n * const connectionString = \"<connection-string>\"\n * const tableName = \"<tableName>\"\n * const client = TableClient.fromConnectionString(connectionString, tableName);\n * const actions = [\n * [\"create\", {partitionKey: \"p1\", rowKey: \"1\", data: \"test1\"}],\n * [\"delete\", {partitionKey: \"p1\", rowKey: \"2\"}],\n * [\"update\", {partitionKey: \"p1\", rowKey: \"3\", data: \"newTest\"}, \"Merge\"]\n * ]\n * const result = await client.submitTransaction(actions);\n * ```\n *\n * Example usage with TableTransaction:\n * ```js\n * const { TableClient } = require(\"@azure/data-tables\");\n * const connectionString = \"<connection-string>\"\n * const tableName = \"<tableName>\"\n * const client = TableClient.fromConnectionString(connectionString, tableName);\n * const transaction = new TableTransaction();\n * // Call the available action in the TableTransaction object\n * transaction.create({partitionKey: \"p1\", rowKey: \"1\", data: \"test1\"});\n * transaction.delete(\"p1\", \"2\");\n * transaction.update({partitionKey: \"p1\", rowKey: \"3\", data: \"newTest\"}, \"Merge\")\n * // submitTransaction with the actions list on the transaction.\n * const result = await client.submitTransaction(transaction.actions);\n * ```\n *\n * @param actions - tuple that contains the action to perform, and the entity to perform the action with\n */\n public async submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse> {\n const partitionKey = actions[0][1].partitionKey;\n const transactionId = Uuid.generateUuid();\n const changesetId = Uuid.generateUuid();\n\n if (!this.transactionClient) {\n // Add pipeline\n this.transactionClient = new InternalTableTransaction(\n this.url,\n partitionKey,\n transactionId,\n changesetId,\n this.clientOptions,\n new TableClient(this.url, this.tableName),\n this.credential,\n this.allowInsecureConnection\n );\n } else {\n this.transactionClient.reset(transactionId, changesetId, partitionKey);\n }\n\n for (const item of actions) {\n const [action, entity, updateMode = \"Merge\"] = item;\n switch (action) {\n case \"create\":\n this.transactionClient.createEntity(entity);\n break;\n case \"delete\":\n this.transactionClient.deleteEntity(entity.partitionKey, entity.rowKey);\n break;\n case \"update\":\n this.transactionClient.updateEntity(entity, updateMode);\n break;\n case \"upsert\":\n this.transactionClient.upsertEntity(entity, updateMode);\n }\n }\n\n return this.transactionClient.submitTransaction();\n }\n\n /**\n *\n * Creates an instance of TableClient 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 TableClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n tableName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableClientOptions\n ): TableClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n if (credential) {\n return new TableClient(url, tableName, credential, clientOptions);\n } else {\n return new TableClient(url, tableName, clientOptions);\n }\n }\n}\n\ntype InternalQueryOptions = TableEntityQueryOptions & { top?: number };\ninterface InternalListTableEntitiesOptions extends ListTableEntitiesOptions {\n queryOptions?: InternalQueryOptions;\n /**\n * An entity query continuation token from a previous call.\n */\n continuationToken?: string;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableClient.js","sourceRoot":"","sources":["../../src/TableClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,oBAAoB,CAAC;AA+B5B,OAAO,EAAE,eAAe,EAAmC,MAAM,aAAa,CAAC;AAC/E,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;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E,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SACnE;aAAM;YACL,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;SACvD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport \"@azure/core-paging\";\nimport {\n CreateTableEntityResponse,\n DeleteTableEntityOptions,\n GetAccessPolicyResponse,\n GetTableEntityOptions,\n GetTableEntityResponse,\n ListTableEntitiesOptions,\n SignedIdentifier,\n TableServiceClientOptions as TableClientOptions,\n TableEntity,\n TableEntityQueryOptions,\n TableEntityResult,\n TableEntityResultPage,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n} from \"./models\";\nimport {\n DeleteTableEntityResponse,\n SetAccessPolicyResponse,\n UpdateEntityResponse,\n UpsertEntityResponse,\n} from \"./generatedModels\";\nimport {\n FullOperationResponse,\n InternalClientPipelineOptions,\n OperationOptions,\n ServiceClient,\n} from \"@azure/core-client\";\nimport { GeneratedClient, TableDeleteEntityOptionalParams } from \"./generated\";\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 { decodeContinuationToken, encodeContinuationToken } from \"./utils/continuationToken\";\nimport {\n deserialize,\n deserializeObjectsArray,\n deserializeSignedIdentifier,\n serialize,\n serializeQueryOptions,\n serializeSignedIdentifiers,\n} from \"./serialization\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { InternalTableTransaction } from \"./TableTransaction\";\nimport { ListEntitiesResponse } from \"./utils/internalModels\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { Table } from \"./generated/operationsInterfaces\";\nimport { TableQueryEntitiesOptionalParams } from \"./generated/models\";\nimport { Uuid } from \"./utils/uuid\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy\";\nimport { createSpan } from \"./utils/tracing\";\nimport { escapeQuotes } from \"./odata\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint\";\nimport { isCredential } from \"./utils/isCredential\";\nimport { logger } from \"./logger\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy\";\n\n/**\n * A TableClient represents a Client to the Azure Tables service allowing you\n * to perform operations on a single table.\n */\nexport class TableClient {\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 generatedClient: ServiceClient;\n private credential?: NamedKeyCredential | SASCredential | TokenCredential;\n private transactionClient?: InternalTableTransaction;\n private clientOptions: TableClientOptions;\n private readonly allowInsecureConnection: boolean;\n\n /**\n * Name of the table to perform operations on.\n */\n public readonly tableName: string;\n\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - NamedKeyCredential used to authenticate requests. Only Supported for Node\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using an account name/key:\n *\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * sharedKeyCredential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: NamedKeyCredential,\n options?: TableClientOptions\n );\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - SASCredential used to authenticate requests\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using a SAS Token:\n *\n * ```js\n * const { AzureSASCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<sas-token>\";\n * const tableName = \"<table name>\";\n * const sasCredential = new AzureSASCredential(sasToken);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * sasCredential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: SASCredential,\n options?: TableClientOptions\n );\n /**\n * Creates a new instance of the TableClient 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 tableName - the name of the table\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```js\n * cons { DefaultAzureCredential } = require(\"@azure/identity\");\n * const { AzureSASCredential, TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<sas-token>\";\n * const tableName = \"<table name>\";\n * const credential = new DefaultAzureCredential();\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * tableName,\n * credential\n * );\n * ```\n */\n constructor(\n url: string,\n tableName: string,\n credential: TokenCredential,\n options?: TableClientOptions\n );\n /**\n * Creates an instance of TableClient.\n *\n * @param url - A Client string pointing to Azure Storage table service, 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 tableName - the name of the table\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example appending a SAS token:\n *\n * ```js\n * const { TableClient } = require(\"@azure/data-tables\");\n * const account = \"<storage account name>\";\n * const sasToken = \"<SAS token>\";\n * const tableName = \"<table name>\";\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * `${tableName}`\n * );\n * ```\n */\n constructor(url: string, tableName: string, options?: TableClientOptions);\n constructor(\n url: string,\n tableName: string,\n credentialOrOptions?: NamedKeyCredential | SASCredential | TableClientOptions | TokenCredential,\n options: TableClientOptions = {}\n ) {\n this.url = url;\n this.tableName = tableName;\n\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n this.credential = credential;\n\n this.clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n this.allowInsecureConnection = this.clientOptions.allowInsecureConnection ?? false;\n this.clientOptions.endpoint = this.clientOptions.endpoint || this.url;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...this.clientOptions,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n ...(isTokenCredential(this.credential) && {\n credential: this.credential,\n credentialScopes: STORAGE_SCOPE,\n }),\n };\n\n const generatedClient = new GeneratedClient(this.url, internalPipelineOptions);\n if (isNamedKeyCredential(credential)) {\n generatedClient.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n generatedClient.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n if (isCosmosEndpoint(this.url)) {\n generatedClient.pipeline.addPolicy(cosmosPatchPolicy());\n }\n\n this.generatedClient = generatedClient;\n this.table = generatedClient.table;\n this.pipeline = generatedClient.pipeline;\n }\n\n /**\n * Permanently deletes the current table with all of its entities.\n * @param options - The options parameters.\n *\n * ### Example deleting a table\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // calling deleteTable will delete the table used\n * // to instantiate the TableClient.\n * // Note: If the table doesn't exist this function doesn't fail.\n * await client.deleteTable();\n * ```\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async deleteTable(options: OperationOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"TableClient-deleteTable\", options);\n try {\n await this.table.delete(this.tableName, updatedOptions);\n } catch (e) {\n if (e.statusCode === 404) {\n logger.info(\"TableClient-deleteTable: Table doesn't exist\");\n } else {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n }\n } finally {\n span.end();\n }\n }\n\n /**\n * Creates a table with the tableName passed to the client constructor\n * @param options - The options parameters.\n *\n * ### Example creating a table\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // calling create table will create the table used\n * // to instantiate the TableClient.\n * // Note: If the table already\n * // exists this function doesn't throw.\n * await client.createTable();\n * ```\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async createTable(options: OperationOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"TableClient-createTable\", options);\n try {\n await this.table.create({ name: this.tableName }, updatedOptions);\n } catch (e) {\n handleTableAlreadyExists(e, { ...updatedOptions, span, logger, tableName: this.tableName });\n } finally {\n span.end();\n }\n }\n\n /**\n * Returns a single entity in the table.\n * @param partitionKey - The partition key of the entity.\n * @param rowKey - The row key of the entity.\n * @param options - The options parameters.\n *\n * ### Example getting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // getEntity will get a single entity stored in the service that\n * // matches exactly the partitionKey and rowKey used as parameters\n * // to the method.\n * const entity = await client.getEntity(\"<partitionKey>\", \"<rowKey>\");\n * console.log(entity);\n * ```\n */\n public async getEntity<T extends object = Record<string, unknown>>(\n partitionKey: string,\n rowKey: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: GetTableEntityOptions = {}\n ): Promise<GetTableEntityResponse<TableEntityResult<T>>> {\n const { span, updatedOptions } = createSpan(\"TableClient-getEntity\", options);\n\n let parsedBody: any;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n parsedBody = rawResponse.parsedBody;\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n }\n\n try {\n const { disableTypeConversion, queryOptions, ...getEntityOptions } = updatedOptions || {};\n await this.table.queryEntitiesWithPartitionAndRowKey(\n this.tableName,\n escapeQuotes(partitionKey),\n escapeQuotes(rowKey),\n {\n ...getEntityOptions,\n queryOptions: serializeQueryOptions(queryOptions || {}),\n onResponse,\n }\n );\n const tableEntity = deserialize<TableEntityResult<T>>(\n parsedBody,\n disableTypeConversion ?? false\n );\n\n return tableEntity;\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Queries entities in a table.\n * @param options - The options parameters.\n *\n * Example listing entities\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // list entities returns a AsyncIterableIterator\n * // this helps consuming paginated responses by\n * // automatically handling getting the next pages\n * const entities = client.listEntities();\n *\n * // this loop will get all the entities from all the pages\n * // returned by the service\n * for await (const entity of entities) {\n * console.log(entity);\n * }\n * ```\n */\n public listEntities<T extends object = Record<string, unknown>>(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: ListTableEntitiesOptions = {}\n ): PagedAsyncIterableIterator<TableEntityResult<T>, TableEntityResultPage<T>> {\n const tableName = this.tableName;\n const iter = this.listEntitiesAll<T>(tableName, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTableEntitiesOptions = {\n ...options,\n queryOptions: { ...options.queryOptions, top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listEntitiesPage(tableName, pageOptions);\n },\n };\n }\n\n private async *listEntitiesAll<T extends object>(\n tableName: string,\n options?: InternalListTableEntitiesOptions\n ): AsyncIterableIterator<TableEntityResult<T>> {\n const firstPage = await this._listEntities<T>(tableName, options);\n yield* firstPage;\n if (firstPage.continuationToken) {\n const optionsWithContinuation: InternalListTableEntitiesOptions = {\n ...options,\n continuationToken: firstPage.continuationToken,\n };\n for await (const page of this.listEntitiesPage<T>(tableName, optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listEntitiesPage<T extends object>(\n tableName: string,\n options: InternalListTableEntitiesOptions = {}\n ): AsyncIterableIterator<ListEntitiesResponse<TableEntityResult<T>>> {\n const { span, updatedOptions } = createSpan(\"TableClient-listEntitiesPage\", options);\n\n try {\n let result = await this._listEntities<T>(tableName, updatedOptions);\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTableEntitiesOptions = {\n ...updatedOptions,\n continuationToken: result.continuationToken,\n };\n\n result = await this._listEntities(tableName, optionsWithContinuation);\n\n yield result;\n }\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async _listEntities<T extends object>(\n tableName: string,\n options: InternalListTableEntitiesOptions = {}\n ): Promise<TableEntityResultPage<T>> {\n const { disableTypeConversion = false } = options;\n const queryOptions = serializeQueryOptions(options.queryOptions || {});\n const listEntitiesOptions: TableQueryEntitiesOptionalParams = {\n ...options,\n queryOptions,\n };\n\n // If a continuation token is used, decode it and set the next row and partition key\n if (options.continuationToken) {\n const continuationToken = decodeContinuationToken(options.continuationToken);\n listEntitiesOptions.nextRowKey = continuationToken.nextRowKey;\n listEntitiesOptions.nextPartitionKey = continuationToken.nextPartitionKey;\n }\n\n const {\n xMsContinuationNextPartitionKey: nextPartitionKey,\n xMsContinuationNextRowKey: nextRowKey,\n value,\n } = await this.table.queryEntities(tableName, listEntitiesOptions);\n\n const tableEntities = deserializeObjectsArray<TableEntityResult<T>>(\n value ?? [],\n disableTypeConversion\n );\n\n // Encode nextPartitionKey and nextRowKey as a single continuation token and add it as a\n // property to the page.\n const continuationToken = encodeContinuationToken(nextPartitionKey, nextRowKey);\n const page: TableEntityResultPage<T> = Object.assign([...tableEntities], {\n continuationToken,\n });\n\n return page;\n }\n\n /**\n * Insert entity in the table.\n * @param entity - The properties for the table entity.\n * @param options - The options parameters.\n *\n * ### Example creating an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // partitionKey and rowKey are required properties of the entity to create\n * // and accepts any other properties\n * await client.createEntity({partitionKey: \"p1\", rowKey: \"r1\", foo: \"Hello!\"});\n * ```\n */\n public async createEntity<T extends object>(\n entity: TableEntity<T>,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {}\n ): Promise<CreateTableEntityResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-createEntity\", options);\n\n try {\n const { ...createTableEntity } = updatedOptions || {};\n return await this.table.insertEntity(this.tableName, {\n ...createTableEntity,\n tableEntityProperties: serialize(entity),\n responsePreference: \"return-no-content\",\n });\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Deletes the specified entity in the table.\n * @param partitionKey - The partition key of the entity.\n * @param rowKey - The row key of the entity.\n * @param options - The options parameters.\n *\n * ### Example deleting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * // deleteEntity deletes the entity that matches\n * // exactly the partitionKey and rowKey passed as parameters\n * await client.deleteEntity(\"<partitionKey>\", \"<rowKey>\")\n * ```\n */\n public async deleteEntity(\n partitionKey: string,\n rowKey: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: DeleteTableEntityOptions = {}\n ): Promise<DeleteTableEntityResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-deleteEntity\", options);\n\n try {\n const { etag = \"*\", ...rest } = updatedOptions || {};\n const deleteOptions: TableDeleteEntityOptionalParams = {\n ...rest,\n };\n return await this.table.deleteEntity(\n this.tableName,\n escapeQuotes(partitionKey),\n escapeQuotes(rowKey),\n etag,\n deleteOptions\n );\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Update an entity in the table.\n * @param entity - The properties of the entity to be updated.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n *\n * ### Example updating an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * const entity = {partitionKey: \"p1\", rowKey: \"r1\", bar: \"updatedBar\"};\n *\n * // Update uses update mode \"Merge\" as default\n * // merge means that update will match a stored entity\n * // that has the same partitionKey and rowKey as the entity\n * // passed to the method and then will only update the properties present in it.\n * // Any other properties that are not defined in the entity passed to updateEntity\n * // will remain as they are in the service\n * await client.updateEntity(entity)\n *\n * // We can also set the update mode to Replace, which will match the entity passed\n * // to updateEntity with one stored in the service and replace with the new one.\n * // If there are any missing properties in the entity passed to updateEntity, they\n * // will be removed from the entity stored in the service\n * await client.updateEntity(entity, \"Replace\")\n * ```\n */\n public async updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode = \"Merge\",\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: UpdateTableEntityOptions = {}\n ): Promise<UpdateEntityResponse> {\n const { span, updatedOptions } = createSpan(`TableClient-updateEntity-${mode}`, options);\n\n try {\n const partitionKey = escapeQuotes(entity.partitionKey);\n const rowKey = escapeQuotes(entity.rowKey);\n\n const { etag = \"*\", ...updateEntityOptions } = updatedOptions || {};\n if (mode === \"Merge\") {\n return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ifMatch: etag,\n ...updateEntityOptions,\n });\n }\n if (mode === \"Replace\") {\n return await this.table.updateEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ifMatch: etag,\n ...updateEntityOptions,\n });\n }\n\n throw new Error(`Unexpected value for update mode: ${mode}`);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Upsert an entity in the table.\n * @param entity - The properties for the table entity.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n *\n * ### Example upserting an entity\n * ```js\n * const { AzureNamedKeyCredential, TableClient } = require(\"@azure/data-tables\")\n * const account = \"<storage account name>\";\n * const accountKey = \"<account key>\"\n * const tableName = \"<table name>\";\n * const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);\n *\n * const client = new TableClient(\n * `https://${account}.table.core.windows.net`,\n * `${tableName}`,\n * sharedKeyCredential\n * );\n *\n * const entity = {partitionKey: \"p1\", rowKey: \"r1\", bar: \"updatedBar\"};\n *\n * // Upsert uses update mode \"Merge\" as default.\n * // This behaves similarly to update but creates the entity\n * // if it doesn't exist in the service\n * await client.upsertEntity(entity)\n *\n * // We can also set the update mode to Replace.\n * // This behaves similarly to update but creates the entity\n * // if it doesn't exist in the service\n * await client.upsertEntity(entity, \"Replace\")\n * ```\n */\n public async upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode = \"Merge\",\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {}\n ): Promise<UpsertEntityResponse> {\n const { span, updatedOptions } = createSpan(`TableClient-upsertEntity-${mode}`, options);\n\n try {\n const partitionKey = escapeQuotes(entity.partitionKey);\n const rowKey = escapeQuotes(entity.rowKey);\n\n if (mode === \"Merge\") {\n return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ...updatedOptions,\n });\n }\n\n if (mode === \"Replace\") {\n return await this.table.updateEntity(this.tableName, partitionKey, rowKey, {\n tableEntityProperties: serialize(entity),\n ...updatedOptions,\n });\n }\n throw new Error(`Unexpected value for update mode: ${mode}`);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Retrieves details about any stored access policies specified on the table that may be used with\n * Shared Access Signatures.\n * @param options - The options parameters.\n */\n public async getAccessPolicy(options: OperationOptions = {}): Promise<GetAccessPolicyResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-getAccessPolicy\", options);\n try {\n const signedIdentifiers = await this.table.getAccessPolicy(this.tableName, updatedOptions);\n return deserializeSignedIdentifier(signedIdentifiers);\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Sets stored access policies for the table that may be used with Shared Access Signatures.\n * @param tableAcl - The Access Control List for the table.\n * @param options - The options parameters.\n */\n public async setAccessPolicy(\n tableAcl: SignedIdentifier[],\n options: OperationOptions = {}\n ): Promise<SetAccessPolicyResponse> {\n const { span, updatedOptions } = createSpan(\"TableClient-setAccessPolicy\", options);\n try {\n const serlializedAcl = serializeSignedIdentifiers(tableAcl);\n return await this.table.setAccessPolicy(this.tableName, {\n ...updatedOptions,\n tableAcl: serlializedAcl,\n });\n } catch (e) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Submits a Transaction which is composed of a set of actions. You can provide the actions as a list\n * or you can use {@link TableTransaction} to help building the transaction.\n *\n * Example usage:\n * ```typescript\n * const { TableClient } = require(\"@azure/data-tables\");\n * const connectionString = \"<connection-string>\"\n * const tableName = \"<tableName>\"\n * const client = TableClient.fromConnectionString(connectionString, tableName);\n * const actions = [\n * [\"create\", {partitionKey: \"p1\", rowKey: \"1\", data: \"test1\"}],\n * [\"delete\", {partitionKey: \"p1\", rowKey: \"2\"}],\n * [\"update\", {partitionKey: \"p1\", rowKey: \"3\", data: \"newTest\"}, \"Merge\"]\n * ]\n * const result = await client.submitTransaction(actions);\n * ```\n *\n * Example usage with TableTransaction:\n * ```js\n * const { TableClient } = require(\"@azure/data-tables\");\n * const connectionString = \"<connection-string>\"\n * const tableName = \"<tableName>\"\n * const client = TableClient.fromConnectionString(connectionString, tableName);\n * const transaction = new TableTransaction();\n * // Call the available action in the TableTransaction object\n * transaction.create({partitionKey: \"p1\", rowKey: \"1\", data: \"test1\"});\n * transaction.delete(\"p1\", \"2\");\n * transaction.update({partitionKey: \"p1\", rowKey: \"3\", data: \"newTest\"}, \"Merge\")\n * // submitTransaction with the actions list on the transaction.\n * const result = await client.submitTransaction(transaction.actions);\n * ```\n *\n * @param actions - tuple that contains the action to perform, and the entity to perform the action with\n */\n public async submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse> {\n const partitionKey = actions[0][1].partitionKey;\n const transactionId = Uuid.generateUuid();\n const changesetId = Uuid.generateUuid();\n\n if (!this.transactionClient) {\n // Add pipeline\n this.transactionClient = new InternalTableTransaction(\n this.url,\n partitionKey,\n transactionId,\n changesetId,\n this.generatedClient,\n new TableClient(this.url, this.tableName),\n this.credential,\n this.allowInsecureConnection\n );\n } else {\n this.transactionClient.reset(transactionId, changesetId, partitionKey);\n }\n\n for (const item of actions) {\n const [action, entity, updateMode = \"Merge\"] = item;\n switch (action) {\n case \"create\":\n this.transactionClient.createEntity(entity);\n break;\n case \"delete\":\n this.transactionClient.deleteEntity(entity.partitionKey, entity.rowKey);\n break;\n case \"update\":\n this.transactionClient.updateEntity(entity, updateMode);\n break;\n case \"upsert\":\n this.transactionClient.upsertEntity(entity, updateMode);\n }\n }\n\n return this.transactionClient.submitTransaction();\n }\n\n /**\n *\n * Creates an instance of TableClient 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 TableClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n tableName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableClientOptions\n ): TableClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n if (credential) {\n return new TableClient(url, tableName, credential, clientOptions);\n } else {\n return new TableClient(url, tableName, clientOptions);\n }\n }\n}\n\ntype InternalQueryOptions = TableEntityQueryOptions & { top?: number };\ninterface InternalListTableEntitiesOptions extends ListTableEntitiesOptions {\n queryOptions?: InternalQueryOptions;\n /**\n * An entity query continuation token from a previous call.\n */\n continuationToken?: string;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n}\n"]}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import {
|
|
4
|
-
import { ServiceClient, serializationPolicy, serializationPolicyName, } from "@azure/core-client";
|
|
3
|
+
import { serializationPolicy, serializationPolicyName, } from "@azure/core-client";
|
|
5
4
|
import { RestError, createHttpHeaders, createPipelineRequest, } from "@azure/core-rest-pipeline";
|
|
6
5
|
import { getInitialTransactionBody, getTransactionHttpRequestBody, } from "./utils/transactionHelpers";
|
|
7
6
|
import { transactionHeaderFilterPolicy, transactionHeaderFilterPolicyName, transactionRequestAssemblePolicy, transactionRequestAssemblePolicyName, } from "./TablePolicies";
|
|
8
7
|
import { SpanStatusCode } from "@azure/core-tracing";
|
|
9
8
|
import { cosmosPatchPolicy } from "./cosmosPathPolicy";
|
|
10
9
|
import { createSpan } from "./utils/tracing";
|
|
11
|
-
import { getAuthorizationHeader } from "./tablesNamedCredentialPolicy";
|
|
12
10
|
import { getTransactionHeaders } from "./utils/transactionHeaders";
|
|
13
11
|
import { isCosmosEndpoint } from "./utils/isCosmosEndpoint";
|
|
14
|
-
import { signURLWithSAS } from "./tablesSASTokenPolicy";
|
|
15
|
-
import { STORAGE_SCOPE } from "./utils/constants";
|
|
16
12
|
/**
|
|
17
13
|
* Helper to build a list of transaction actions
|
|
18
14
|
*/
|
|
@@ -61,9 +57,8 @@ export class InternalTableTransaction {
|
|
|
61
57
|
* @param partitionKey - partition key
|
|
62
58
|
* @param credential - credential to authenticate the transaction request
|
|
63
59
|
*/
|
|
64
|
-
constructor(url, partitionKey, transactionId, changesetId,
|
|
65
|
-
this.
|
|
66
|
-
this.credential = credential;
|
|
60
|
+
constructor(url, partitionKey, transactionId, changesetId, client, interceptClient, credential, allowInsecureConnection = false) {
|
|
61
|
+
this.client = client;
|
|
67
62
|
this.url = url;
|
|
68
63
|
this.interceptClient = interceptClient;
|
|
69
64
|
this.allowInsecureConnection = allowInsecureConnection;
|
|
@@ -157,12 +152,6 @@ export class InternalTableTransaction {
|
|
|
157
152
|
async submitTransaction() {
|
|
158
153
|
await Promise.all(this.resetableState.pendingOperations);
|
|
159
154
|
const body = getTransactionHttpRequestBody(this.resetableState.bodyParts, this.resetableState.transactionId, this.resetableState.changesetId);
|
|
160
|
-
const options = this.clientOptions;
|
|
161
|
-
if (isTokenCredential(this.credential)) {
|
|
162
|
-
options.credentialScopes = STORAGE_SCOPE;
|
|
163
|
-
options.credential = this.credential;
|
|
164
|
-
}
|
|
165
|
-
const client = new ServiceClient(options);
|
|
166
155
|
const headers = getTransactionHeaders(this.resetableState.transactionId);
|
|
167
156
|
const { span, updatedOptions } = createSpan("TableTransaction-submitTransaction", {});
|
|
168
157
|
const request = createPipelineRequest({
|
|
@@ -173,15 +162,8 @@ export class InternalTableTransaction {
|
|
|
173
162
|
tracingOptions: updatedOptions.tracingOptions,
|
|
174
163
|
allowInsecureConnection: this.allowInsecureConnection,
|
|
175
164
|
});
|
|
176
|
-
if (isNamedKeyCredential(this.credential)) {
|
|
177
|
-
const authHeader = getAuthorizationHeader(request, this.credential);
|
|
178
|
-
request.headers.set("Authorization", authHeader);
|
|
179
|
-
}
|
|
180
|
-
else if (isSASCredential(this.credential)) {
|
|
181
|
-
signURLWithSAS(request, this.credential);
|
|
182
|
-
}
|
|
183
165
|
try {
|
|
184
|
-
const rawTransactionResponse = await client.sendRequest(request);
|
|
166
|
+
const rawTransactionResponse = await this.client.sendRequest(request);
|
|
185
167
|
return parseTransactionResponse(rawTransactionResponse);
|
|
186
168
|
}
|
|
187
169
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTransaction.js","sourceRoot":"","sources":["../../src/TableTransaction.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,GAExB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,SAAS,EACT,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE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KACnB;IAED,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE;QAC3B,IAAI;QACJ,UAAU;QACV,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAkB,EAClB,SAAmB,EACnB,WAAmB,EACnB,QAAiB;IAEjB,yEAAyE;IACzE,sBAAsB;IACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IAC/C,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;QAC7B,QAAQ,CAAC,YAAY,CAAC;YACpB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;KACJ;IAED,+FAA+F;IAC/F,+FAA+F;IAE/F,QAAQ,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;IAClE,QAAQ,CAAC,SAAS,CAAC,6BAA6B,EAAE,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,gCAAgC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7E,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE;YACtC,aAAa,EAAE,CAAC,iCAAiC,CAAC;YAClD,cAAc,EAAE,CAAC,uBAAuB,EAAE,oCAAoC,CAAC;SAChF,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DeleteTableEntityOptions,\n TableEntity,\n TableTransactionEntityResponse,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n TableServiceClientOptions,\n} from \"./models\";\nimport {\n NamedKeyCredential,\n SASCredential,\n TokenCredential,\n isNamedKeyCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport {\n OperationOptions,\n ServiceClient,\n serializationPolicy,\n serializationPolicyName,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport {\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RestError,\n createHttpHeaders,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport {\n getInitialTransactionBody,\n getTransactionHttpRequestBody,\n} from \"./utils/transactionHelpers\";\nimport {\n transactionHeaderFilterPolicy,\n transactionHeaderFilterPolicyName,\n transactionRequestAssemblePolicy,\n transactionRequestAssemblePolicyName,\n} from \"./TablePolicies\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { TableClientLike } from \"./utils/internalModels\";\nimport { TableServiceErrorOdataError } from \"./generated\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy\";\nimport { createSpan } from \"./utils/tracing\";\nimport { getAuthorizationHeader } from \"./tablesNamedCredentialPolicy\";\nimport { getTransactionHeaders } from \"./utils/transactionHeaders\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint\";\nimport { signURLWithSAS } from \"./tablesSASTokenPolicy\";\nimport { STORAGE_SCOPE } from \"./utils/constants\";\n\n/**\n * Helper to build a list of transaction actions\n */\nexport class TableTransaction {\n /**\n * List of actions to perform in a transaction\n */\n public actions: TransactionAction[];\n\n constructor(actions?: TransactionAction[]) {\n this.actions = actions ?? [];\n }\n\n /**\n * Adds a create action to the transaction\n * @param entity - entity to create\n */\n createEntity<T extends object = Record<string, unknown>>(entity: TableEntity<T>): void {\n this.actions.push([\"create\", entity]);\n }\n\n /**\n * Adds a delete action to the transaction\n * @param partitionKey - partition key of the entity to delete\n * @param rowKey - rowKey of the entity to delete\n */\n deleteEntity(partitionKey: string, rowKey: string): void {\n this.actions.push([\"delete\", { partitionKey, rowKey }]);\n }\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateMode - update mode\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\"\n ): void {\n this.actions.push([\"update\", entity, updateMode]);\n }\n\n /**\n * Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one\n * @param entity - entity to upsert\n * @param updateMode - update mode\n */\n upsertEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\"\n ): void {\n this.actions.push([\"upsert\", entity, updateMode]);\n }\n}\n\n/**\n * TableTransaction collects sub-operations that can be submitted together via submitTransaction\n */\nexport class InternalTableTransaction {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * This part of the state can be reset by\n * calling the reset function. Other parts of the state\n * such as the credentials remain the same throughout the life\n * of the instance.\n */\n private resetableState: {\n transactionId: string;\n changesetId: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n partitionKey: string;\n };\n private clientOptions: TableServiceClientOptions;\n private interceptClient: TableClientLike;\n private credential?: NamedKeyCredential | SASCredential | TokenCredential;\n private allowInsecureConnection: boolean;\n\n /**\n * @param url - Tables account url\n * @param partitionKey - partition key\n * @param credential - credential to authenticate the transaction request\n */\n constructor(\n url: string,\n partitionKey: string,\n transactionId: string,\n changesetId: string,\n clientOptions: TableServiceClientOptions,\n interceptClient: TableClientLike,\n credential?: NamedKeyCredential | SASCredential | TokenCredential,\n allowInsecureConnection: boolean = false\n ) {\n this.clientOptions = clientOptions;\n this.credential = credential;\n this.url = url;\n this.interceptClient = interceptClient;\n this.allowInsecureConnection = allowInsecureConnection;\n\n // Initialize Reset-able properties\n this.resetableState = this.initializeSharedState(transactionId, changesetId, partitionKey);\n\n // Depending on the auth method used we need to build the url\n if (!credential) {\n // When the SAS token is provided as part of the URL we need to move it after $batch\n const urlParts = url.split(\"?\");\n this.url = urlParts[0];\n const sas = urlParts.length > 1 ? `?${urlParts[1]}` : \"\";\n this.url = `${this.getUrlWithSlash()}$batch${sas}`;\n } else {\n // When using a SharedKey credential no SAS token is needed\n this.url = `${this.getUrlWithSlash()}$batch`;\n }\n }\n\n /**\n * Resets the state of the Transaction.\n */\n reset(transactionId: string, changesetId: string, partitionKey: string): void {\n this.resetableState = this.initializeSharedState(transactionId, changesetId, partitionKey);\n }\n\n private initializeSharedState(transactionId: string, changesetId: string, partitionKey: string) {\n const pendingOperations: Promise<any>[] = [];\n const bodyParts = getInitialTransactionBody(transactionId, changesetId);\n const isCosmos = isCosmosEndpoint(this.url);\n prepateTransactionPipeline(this.interceptClient.pipeline, bodyParts, changesetId, isCosmos);\n\n return {\n transactionId,\n changesetId,\n partitionKey,\n pendingOperations,\n bodyParts,\n };\n }\n\n /**\n * Adds a createEntity operation to the transaction\n * @param entity - Entity to create\n */\n public createEntity<T extends object>(entity: TableEntity<T>): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n\n /**\n * Adds a createEntity operation to the transaction per each entity in the entities array\n * @param entities - Array of entities to create\n */\n public createEntities<T extends object>(entities: TableEntity<T>[]): void {\n for (const entity of entities) {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n }\n\n /**\n * Adds a deleteEntity operation to the transaction\n * @param partitionKey - Partition key of the entity to delete\n * @param rowKey - Row key of the entity to delete\n * @param options - Options for the delete operation\n */\n public deleteEntity(\n partitionKey: string,\n rowKey: string,\n options?: DeleteTableEntityOptions\n ): void {\n this.checkPartitionKey(partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.deleteEntity(partitionKey, rowKey, options)\n );\n }\n\n /**\n * Adds an updateEntity operation to the transaction\n * @param entity - Entity to update\n * @param mode - Update mode (Merge or Replace)\n * @param options - Options for the update operation\n */\n public updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: UpdateTableEntityOptions\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.updateEntity(entity, mode, options)\n );\n }\n\n /**\n * Adds an upsertEntity operation to the transaction\n * @param entity - The properties for the table entity.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n */\n public upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: OperationOptions\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.upsertEntity(entity, mode, options)\n );\n }\n\n /**\n * Submits the operations in the transaction\n */\n public async submitTransaction(): Promise<TableTransactionResponse> {\n await Promise.all(this.resetableState.pendingOperations);\n const body = getTransactionHttpRequestBody(\n this.resetableState.bodyParts,\n this.resetableState.transactionId,\n this.resetableState.changesetId\n );\n\n const options: ServiceClientOptions = this.clientOptions;\n\n if (isTokenCredential(this.credential)) {\n options.credentialScopes = STORAGE_SCOPE;\n options.credential = this.credential;\n }\n\n const client = new ServiceClient(options);\n\n const headers = getTransactionHeaders(this.resetableState.transactionId);\n\n const { span, updatedOptions } = createSpan(\n \"TableTransaction-submitTransaction\",\n {} as OperationOptions\n );\n const request = createPipelineRequest({\n url: this.url,\n method: \"POST\",\n body,\n headers: createHttpHeaders(headers),\n tracingOptions: updatedOptions.tracingOptions,\n allowInsecureConnection: this.allowInsecureConnection,\n });\n\n if (isNamedKeyCredential(this.credential)) {\n const authHeader = getAuthorizationHeader(request, this.credential);\n request.headers.set(\"Authorization\", authHeader);\n } else if (isSASCredential(this.credential)) {\n signURLWithSAS(request, this.credential);\n }\n\n try {\n const rawTransactionResponse = await client.sendRequest(request);\n return parseTransactionResponse(rawTransactionResponse);\n } catch (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n throw error;\n } finally {\n span.end();\n }\n }\n\n private checkPartitionKey(partitionKey: string): void {\n if (this.resetableState.partitionKey !== partitionKey) {\n throw new Error(\"All operations in a transaction must target the same partitionKey\");\n }\n }\n\n private getUrlWithSlash(): string {\n return this.url.endsWith(\"/\") ? this.url : `${this.url}/`;\n }\n}\n\nexport function parseTransactionResponse(\n transactionResponse: PipelineResponse\n): TableTransactionResponse {\n const subResponsePrefix = `--changesetresponse_`;\n const status = transactionResponse.status;\n const rawBody = transactionResponse.bodyAsText || \"\";\n const splitBody = rawBody.split(subResponsePrefix);\n const isSuccessByStatus = 200 <= status && status < 300;\n\n if (!isSuccessByStatus) {\n handleBodyError(rawBody, status, transactionResponse.request, transactionResponse);\n }\n\n // Dropping the first and last elements as they are the boundaries\n // we just care about sub request content\n const subResponses = splitBody.slice(1, splitBody.length - 1);\n\n const responses: TableTransactionEntityResponse[] = subResponses.map((subResponse) => {\n const statusMatch = subResponse.match(/HTTP\\/1.1 ([0-9]*)/);\n if (statusMatch?.length !== 2) {\n throw new Error(`Couldn't extract status from sub-response:\\n ${subResponse}`);\n }\n const subResponseStatus = Number.parseInt(statusMatch[1]);\n if (!Number.isInteger(subResponseStatus)) {\n throw new Error(`Expected sub-response status to be an integer ${subResponseStatus}`);\n }\n\n const bodyMatch = subResponse.match(/\\{(.*)\\}/);\n if (bodyMatch?.length === 2) {\n handleBodyError(\n bodyMatch[0],\n subResponseStatus,\n transactionResponse.request,\n transactionResponse\n );\n }\n\n const etagMatch = subResponse.match(/ETag: (.*)/);\n const rowKeyMatch = subResponse.match(/RowKey='(.*)'/);\n\n return {\n status: subResponseStatus,\n ...(rowKeyMatch?.length === 2 && { rowKey: rowKeyMatch[1] }),\n ...(etagMatch?.length === 2 && { etag: etagMatch[1] }),\n };\n });\n\n return {\n status,\n subResponses: responses,\n getResponseForEntity: (rowKey: string) => responses.find((r) => r.rowKey === rowKey),\n };\n}\n\nfunction handleBodyError(\n bodyAsText: string,\n statusCode: number,\n request: PipelineRequest,\n response: PipelineResponse\n) {\n let parsedError;\n\n try {\n parsedError = JSON.parse(bodyAsText);\n } catch {\n parsedError = {};\n }\n\n let message = \"Transaction Failed\";\n let code: string | undefined;\n // Only transaction sub-responses return body\n if (parsedError && parsedError[\"odata.error\"]) {\n const error: TableServiceErrorOdataError = parsedError[\"odata.error\"];\n message = error.message?.value ?? message;\n code = error.code;\n }\n\n throw new RestError(message, {\n code,\n statusCode,\n request,\n response,\n });\n}\n\n/**\n * Prepares the transaction pipeline to intercept operations\n * @param pipeline - Client pipeline\n */\nexport function prepateTransactionPipeline(\n pipeline: Pipeline,\n bodyParts: string[],\n changesetId: string,\n isCosmos: boolean\n): void {\n // Fist, we need to clear all the existing policies to make sure we start\n // with a fresh state.\n const policies = pipeline.getOrderedPolicies();\n for (const policy of policies) {\n pipeline.removePolicy({\n name: policy.name,\n });\n }\n\n // With the clear state we now initialize the pipelines required for intercepting the requests.\n // Use transaction assemble policy to assemble request and intercept request from going to wire\n\n pipeline.addPolicy(serializationPolicy(), { phase: \"Serialize\" });\n pipeline.addPolicy(transactionHeaderFilterPolicy());\n pipeline.addPolicy(transactionRequestAssemblePolicy(bodyParts, changesetId));\n if (isCosmos) {\n pipeline.addPolicy(cosmosPatchPolicy(), {\n afterPolicies: [transactionHeaderFilterPolicyName],\n beforePolicies: [serializationPolicyName, transactionRequestAssemblePolicyName],\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableTransaction.js","sourceRoot":"","sources":["../../src/TableTransaction.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAGL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,SAAS,EACT,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAA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,aAAa,EAAE,CAAC,iCAAiC,CAAC;YAClD,cAAc,EAAE,CAAC,uBAAuB,EAAE,oCAAoC,CAAC;SAChF,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DeleteTableEntityOptions,\n TableEntity,\n TableTransactionEntityResponse,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n} from \"./models\";\nimport { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport {\n OperationOptions,\n ServiceClient,\n serializationPolicy,\n serializationPolicyName,\n} from \"@azure/core-client\";\nimport {\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RestError,\n createHttpHeaders,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport {\n getInitialTransactionBody,\n getTransactionHttpRequestBody,\n} from \"./utils/transactionHelpers\";\nimport {\n transactionHeaderFilterPolicy,\n transactionHeaderFilterPolicyName,\n transactionRequestAssemblePolicy,\n transactionRequestAssemblePolicyName,\n} from \"./TablePolicies\";\n\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { TableClientLike } from \"./utils/internalModels\";\nimport { TableServiceErrorOdataError } from \"./generated\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy\";\nimport { createSpan } from \"./utils/tracing\";\nimport { getTransactionHeaders } from \"./utils/transactionHeaders\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint\";\n\n/**\n * Helper to build a list of transaction actions\n */\nexport class TableTransaction {\n /**\n * List of actions to perform in a transaction\n */\n public actions: TransactionAction[];\n\n constructor(actions?: TransactionAction[]) {\n this.actions = actions ?? [];\n }\n\n /**\n * Adds a create action to the transaction\n * @param entity - entity to create\n */\n createEntity<T extends object = Record<string, unknown>>(entity: TableEntity<T>): void {\n this.actions.push([\"create\", entity]);\n }\n\n /**\n * Adds a delete action to the transaction\n * @param partitionKey - partition key of the entity to delete\n * @param rowKey - rowKey of the entity to delete\n */\n deleteEntity(partitionKey: string, rowKey: string): void {\n this.actions.push([\"delete\", { partitionKey, rowKey }]);\n }\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateMode - update mode\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\"\n ): void {\n this.actions.push([\"update\", entity, updateMode]);\n }\n\n /**\n * Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one\n * @param entity - entity to upsert\n * @param updateMode - update mode\n */\n upsertEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\"\n ): void {\n this.actions.push([\"upsert\", entity, updateMode]);\n }\n}\n\n/**\n * TableTransaction collects sub-operations that can be submitted together via submitTransaction\n */\nexport class InternalTableTransaction {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * This part of the state can be reset by\n * calling the reset function. Other parts of the state\n * such as the credentials remain the same throughout the life\n * of the instance.\n */\n private resetableState: {\n transactionId: string;\n changesetId: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n partitionKey: string;\n };\n private interceptClient: TableClientLike;\n private allowInsecureConnection: boolean;\n private client: ServiceClient;\n\n /**\n * @param url - Tables account url\n * @param partitionKey - partition key\n * @param credential - credential to authenticate the transaction request\n */\n constructor(\n url: string,\n partitionKey: string,\n transactionId: string,\n changesetId: string,\n client: ServiceClient,\n interceptClient: TableClientLike,\n credential?: NamedKeyCredential | SASCredential | TokenCredential,\n allowInsecureConnection: boolean = false\n ) {\n this.client = client;\n this.url = url;\n this.interceptClient = interceptClient;\n this.allowInsecureConnection = allowInsecureConnection;\n\n // Initialize Reset-able properties\n this.resetableState = this.initializeSharedState(transactionId, changesetId, partitionKey);\n\n // Depending on the auth method used we need to build the url\n if (!credential) {\n // When the SAS token is provided as part of the URL we need to move it after $batch\n const urlParts = url.split(\"?\");\n this.url = urlParts[0];\n const sas = urlParts.length > 1 ? `?${urlParts[1]}` : \"\";\n this.url = `${this.getUrlWithSlash()}$batch${sas}`;\n } else {\n // When using a SharedKey credential no SAS token is needed\n this.url = `${this.getUrlWithSlash()}$batch`;\n }\n }\n\n /**\n * Resets the state of the Transaction.\n */\n reset(transactionId: string, changesetId: string, partitionKey: string): void {\n this.resetableState = this.initializeSharedState(transactionId, changesetId, partitionKey);\n }\n\n private initializeSharedState(transactionId: string, changesetId: string, partitionKey: string) {\n const pendingOperations: Promise<any>[] = [];\n const bodyParts = getInitialTransactionBody(transactionId, changesetId);\n const isCosmos = isCosmosEndpoint(this.url);\n prepateTransactionPipeline(this.interceptClient.pipeline, bodyParts, changesetId, isCosmos);\n\n return {\n transactionId,\n changesetId,\n partitionKey,\n pendingOperations,\n bodyParts,\n };\n }\n\n /**\n * Adds a createEntity operation to the transaction\n * @param entity - Entity to create\n */\n public createEntity<T extends object>(entity: TableEntity<T>): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n\n /**\n * Adds a createEntity operation to the transaction per each entity in the entities array\n * @param entities - Array of entities to create\n */\n public createEntities<T extends object>(entities: TableEntity<T>[]): void {\n for (const entity of entities) {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n }\n\n /**\n * Adds a deleteEntity operation to the transaction\n * @param partitionKey - Partition key of the entity to delete\n * @param rowKey - Row key of the entity to delete\n * @param options - Options for the delete operation\n */\n public deleteEntity(\n partitionKey: string,\n rowKey: string,\n options?: DeleteTableEntityOptions\n ): void {\n this.checkPartitionKey(partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.deleteEntity(partitionKey, rowKey, options)\n );\n }\n\n /**\n * Adds an updateEntity operation to the transaction\n * @param entity - Entity to update\n * @param mode - Update mode (Merge or Replace)\n * @param options - Options for the update operation\n */\n public updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: UpdateTableEntityOptions\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.updateEntity(entity, mode, options)\n );\n }\n\n /**\n * Adds an upsertEntity operation to the transaction\n * @param entity - The properties for the table entity.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n */\n public upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: OperationOptions\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.resetableState.pendingOperations.push(\n this.interceptClient.upsertEntity(entity, mode, options)\n );\n }\n\n /**\n * Submits the operations in the transaction\n */\n public async submitTransaction(): Promise<TableTransactionResponse> {\n await Promise.all(this.resetableState.pendingOperations);\n const body = getTransactionHttpRequestBody(\n this.resetableState.bodyParts,\n this.resetableState.transactionId,\n this.resetableState.changesetId\n );\n\n const headers = getTransactionHeaders(this.resetableState.transactionId);\n\n const { span, updatedOptions } = createSpan(\n \"TableTransaction-submitTransaction\",\n {} as OperationOptions\n );\n const request = createPipelineRequest({\n url: this.url,\n method: \"POST\",\n body,\n headers: createHttpHeaders(headers),\n tracingOptions: updatedOptions.tracingOptions,\n allowInsecureConnection: this.allowInsecureConnection,\n });\n\n try {\n const rawTransactionResponse = await this.client.sendRequest(request);\n return parseTransactionResponse(rawTransactionResponse);\n } catch (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n throw error;\n } finally {\n span.end();\n }\n }\n\n private checkPartitionKey(partitionKey: string): void {\n if (this.resetableState.partitionKey !== partitionKey) {\n throw new Error(\"All operations in a transaction must target the same partitionKey\");\n }\n }\n\n private getUrlWithSlash(): string {\n return this.url.endsWith(\"/\") ? this.url : `${this.url}/`;\n }\n}\n\nexport function parseTransactionResponse(\n transactionResponse: PipelineResponse\n): TableTransactionResponse {\n const subResponsePrefix = `--changesetresponse_`;\n const status = transactionResponse.status;\n const rawBody = transactionResponse.bodyAsText || \"\";\n const splitBody = rawBody.split(subResponsePrefix);\n const isSuccessByStatus = 200 <= status && status < 300;\n\n if (!isSuccessByStatus) {\n handleBodyError(rawBody, status, transactionResponse.request, transactionResponse);\n }\n\n // Dropping the first and last elements as they are the boundaries\n // we just care about sub request content\n const subResponses = splitBody.slice(1, splitBody.length - 1);\n\n const responses: TableTransactionEntityResponse[] = subResponses.map((subResponse) => {\n const statusMatch = subResponse.match(/HTTP\\/1.1 ([0-9]*)/);\n if (statusMatch?.length !== 2) {\n throw new Error(`Couldn't extract status from sub-response:\\n ${subResponse}`);\n }\n const subResponseStatus = Number.parseInt(statusMatch[1]);\n if (!Number.isInteger(subResponseStatus)) {\n throw new Error(`Expected sub-response status to be an integer ${subResponseStatus}`);\n }\n\n const bodyMatch = subResponse.match(/\\{(.*)\\}/);\n if (bodyMatch?.length === 2) {\n handleBodyError(\n bodyMatch[0],\n subResponseStatus,\n transactionResponse.request,\n transactionResponse\n );\n }\n\n const etagMatch = subResponse.match(/ETag: (.*)/);\n const rowKeyMatch = subResponse.match(/RowKey='(.*)'/);\n\n return {\n status: subResponseStatus,\n ...(rowKeyMatch?.length === 2 && { rowKey: rowKeyMatch[1] }),\n ...(etagMatch?.length === 2 && { etag: etagMatch[1] }),\n };\n });\n\n return {\n status,\n subResponses: responses,\n getResponseForEntity: (rowKey: string) => responses.find((r) => r.rowKey === rowKey),\n };\n}\n\nfunction handleBodyError(\n bodyAsText: string,\n statusCode: number,\n request: PipelineRequest,\n response: PipelineResponse\n) {\n let parsedError;\n\n try {\n parsedError = JSON.parse(bodyAsText);\n } catch {\n parsedError = {};\n }\n\n let message = \"Transaction Failed\";\n let code: string | undefined;\n // Only transaction sub-responses return body\n if (parsedError && parsedError[\"odata.error\"]) {\n const error: TableServiceErrorOdataError = parsedError[\"odata.error\"];\n message = error.message?.value ?? message;\n code = error.code;\n }\n\n throw new RestError(message, {\n code,\n statusCode,\n request,\n response,\n });\n}\n\n/**\n * Prepares the transaction pipeline to intercept operations\n * @param pipeline - Client pipeline\n */\nexport function prepateTransactionPipeline(\n pipeline: Pipeline,\n bodyParts: string[],\n changesetId: string,\n isCosmos: boolean\n): void {\n // Fist, we need to clear all the existing policies to make sure we start\n // with a fresh state.\n const policies = pipeline.getOrderedPolicies();\n for (const policy of policies) {\n pipeline.removePolicy({\n name: policy.name,\n });\n }\n\n // With the clear state we now initialize the pipelines required for intercepting the requests.\n // Use transaction assemble policy to assemble request and intercept request from going to wire\n\n pipeline.addPolicy(serializationPolicy(), { phase: \"Serialize\" });\n pipeline.addPolicy(transactionHeaderFilterPolicy());\n pipeline.addPolicy(transactionRequestAssemblePolicy(bodyParts, changesetId));\n if (isCosmos) {\n pipeline.addPolicy(cosmosPatchPolicy(), {\n afterPolicies: [transactionHeaderFilterPolicyName],\n beforePolicies: [serializationPolicyName, transactionRequestAssemblePolicyName],\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/data-tables",
|
|
3
|
-
"version": "13.0.2-alpha.
|
|
3
|
+
"version": "13.0.2-alpha.20220214.1",
|
|
4
4
|
"description": "An isomorphic client library for the Azure Tables service.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
27
|
-
"build:browser": "tsc -p . &&
|
|
28
|
-
"build:node": "tsc -p . &&
|
|
27
|
+
"build:browser": "tsc -p . && dev-tool run bundle",
|
|
28
|
+
"build:node": "tsc -p . && dev-tool run bundle",
|
|
29
29
|
"build:samples": "echo Obsolete.",
|
|
30
|
-
"build:test": "tsc -p . &&
|
|
30
|
+
"build:test": "tsc -p . && dev-tool run bundle",
|
|
31
31
|
"build:types": "downlevel-dts types/latest types/3.1",
|
|
32
|
-
"build": "npm run clean && tsc -p . &&
|
|
32
|
+
"build": "npm run clean && tsc -p . && dev-tool run bundle && api-extractor run --local && npm run build:types",
|
|
33
33
|
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
34
34
|
"clean": "rimraf dist dist-* types *.tgz *.log",
|
|
35
35
|
"execute:samples": "dev-tool samples run samples-dev",
|
|
36
36
|
"extract-api": "tsc -p . && api-extractor run --local",
|
|
37
37
|
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
38
38
|
"generate:client": "autorest --typescript ./swagger/README.md",
|
|
39
|
-
"integration-test:browser": "
|
|
40
|
-
"integration-test:node": "
|
|
39
|
+
"integration-test:browser": "dev-tool run test:browser",
|
|
40
|
+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 --exclude 'dist-esm/test/**/browser/*.spec.js' 'dist-esm/test/**/*.spec.js'",
|
|
41
41
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
42
42
|
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
|
43
43
|
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
|
|
46
46
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
47
47
|
"test": "npm run clean && npm run build:test && npm run unit-test",
|
|
48
|
-
"unit-test:browser": "
|
|
49
|
-
"unit-test:node": "
|
|
48
|
+
"unit-test:browser": "dev-tool run test:browser",
|
|
49
|
+
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
|
50
50
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
@@ -89,11 +89,6 @@
|
|
|
89
89
|
"@azure/identity": "^2.0.1",
|
|
90
90
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
91
91
|
"@microsoft/api-extractor": "^7.18.11",
|
|
92
|
-
"@rollup/plugin-commonjs": "11.0.2",
|
|
93
|
-
"@rollup/plugin-json": "^4.0.0",
|
|
94
|
-
"@rollup/plugin-multi-entry": "^3.0.0",
|
|
95
|
-
"@rollup/plugin-node-resolve": "^8.0.0",
|
|
96
|
-
"@rollup/plugin-replace": "^2.2.0",
|
|
97
92
|
"@types/chai": "^4.1.6",
|
|
98
93
|
"@types/mocha": "^7.0.2",
|
|
99
94
|
"@types/node": "^12.0.0",
|
|
@@ -121,18 +116,13 @@
|
|
|
121
116
|
"prettier": "^2.5.1",
|
|
122
117
|
"nyc": "^15.0.0",
|
|
123
118
|
"rimraf": "^3.0.0",
|
|
124
|
-
"rollup": "^1.16.3",
|
|
125
|
-
"rollup-plugin-sourcemaps": "^0.4.2",
|
|
126
|
-
"rollup-plugin-terser": "^5.1.1",
|
|
127
|
-
"rollup-plugin-visualizer": "^4.0.4",
|
|
128
119
|
"sinon": "^9.0.2",
|
|
129
120
|
"typescript": "~4.2.0",
|
|
130
121
|
"util": "^0.12.1",
|
|
131
122
|
"dotenv": "^8.2.0",
|
|
132
|
-
"@azure-tools/test-recorder": "
|
|
123
|
+
"@azure-tools/test-recorder": ">=2.0.0-alpha <2.0.0-alphb",
|
|
124
|
+
"@azure-tools/test-credential": ">=1.0.0-alpha <1.0.0-alphb",
|
|
133
125
|
"@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
|
|
134
|
-
"rollup-plugin-shim": "^1.0.0",
|
|
135
|
-
"@rollup/plugin-inject": "^4.0.0",
|
|
136
126
|
"ts-node": "^10.0.0"
|
|
137
127
|
},
|
|
138
128
|
"//sampleConfiguration": {
|