@azure/data-tables 13.2.1-alpha.20221129.1 → 13.2.1-alpha.20230112.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -30
- package/dist/index.js.map +1 -1
- package/dist-esm/src/TableClient.js +7 -12
- package/dist-esm/src/TableClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js +12 -18
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/package.json +1 -1
- package/types/3.1/data-tables.d.ts +0 -1
- package/types/latest/data-tables.d.ts +0 -1
- package/types/latest/tsdoc-metadata.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3916,8 +3916,8 @@ class InternalTableTransaction {
|
|
|
3916
3916
|
this.url = url;
|
|
3917
3917
|
this.interceptClient = interceptClient;
|
|
3918
3918
|
this.allowInsecureConnection = allowInsecureConnection;
|
|
3919
|
-
// Initialize
|
|
3920
|
-
this.
|
|
3919
|
+
// Initialize the state
|
|
3920
|
+
this.state = this.initializeState(transactionId, changesetId, partitionKey);
|
|
3921
3921
|
// Depending on the auth method used we need to build the url
|
|
3922
3922
|
if (!credential) {
|
|
3923
3923
|
// When the SAS token is provided as part of the URL we need to move it after $batch
|
|
@@ -3931,13 +3931,7 @@ class InternalTableTransaction {
|
|
|
3931
3931
|
this.url = `${this.getUrlWithSlash()}$batch`;
|
|
3932
3932
|
}
|
|
3933
3933
|
}
|
|
3934
|
-
|
|
3935
|
-
* Resets the state of the Transaction.
|
|
3936
|
-
*/
|
|
3937
|
-
reset(transactionId, changesetId, partitionKey) {
|
|
3938
|
-
this.resetableState = this.initializeSharedState(transactionId, changesetId, partitionKey);
|
|
3939
|
-
}
|
|
3940
|
-
initializeSharedState(transactionId, changesetId, partitionKey) {
|
|
3934
|
+
initializeState(transactionId, changesetId, partitionKey) {
|
|
3941
3935
|
const pendingOperations = [];
|
|
3942
3936
|
const bodyParts = getInitialTransactionBody(transactionId, changesetId);
|
|
3943
3937
|
const isCosmos = isCosmosEndpoint(this.url);
|
|
@@ -3956,7 +3950,7 @@ class InternalTableTransaction {
|
|
|
3956
3950
|
*/
|
|
3957
3951
|
createEntity(entity) {
|
|
3958
3952
|
this.checkPartitionKey(entity.partitionKey);
|
|
3959
|
-
this.
|
|
3953
|
+
this.state.pendingOperations.push(this.interceptClient.createEntity(entity));
|
|
3960
3954
|
}
|
|
3961
3955
|
/**
|
|
3962
3956
|
* Adds a createEntity operation to the transaction per each entity in the entities array
|
|
@@ -3965,7 +3959,7 @@ class InternalTableTransaction {
|
|
|
3965
3959
|
createEntities(entities) {
|
|
3966
3960
|
for (const entity of entities) {
|
|
3967
3961
|
this.checkPartitionKey(entity.partitionKey);
|
|
3968
|
-
this.
|
|
3962
|
+
this.state.pendingOperations.push(this.interceptClient.createEntity(entity));
|
|
3969
3963
|
}
|
|
3970
3964
|
}
|
|
3971
3965
|
/**
|
|
@@ -3976,7 +3970,7 @@ class InternalTableTransaction {
|
|
|
3976
3970
|
*/
|
|
3977
3971
|
deleteEntity(partitionKey, rowKey, options) {
|
|
3978
3972
|
this.checkPartitionKey(partitionKey);
|
|
3979
|
-
this.
|
|
3973
|
+
this.state.pendingOperations.push(this.interceptClient.deleteEntity(partitionKey, rowKey, options));
|
|
3980
3974
|
}
|
|
3981
3975
|
/**
|
|
3982
3976
|
* Adds an updateEntity operation to the transaction
|
|
@@ -3986,7 +3980,7 @@ class InternalTableTransaction {
|
|
|
3986
3980
|
*/
|
|
3987
3981
|
updateEntity(entity, mode, options) {
|
|
3988
3982
|
this.checkPartitionKey(entity.partitionKey);
|
|
3989
|
-
this.
|
|
3983
|
+
this.state.pendingOperations.push(this.interceptClient.updateEntity(entity, mode, options));
|
|
3990
3984
|
}
|
|
3991
3985
|
/**
|
|
3992
3986
|
* Adds an upsertEntity operation to the transaction
|
|
@@ -3998,15 +3992,15 @@ class InternalTableTransaction {
|
|
|
3998
3992
|
*/
|
|
3999
3993
|
upsertEntity(entity, mode, options) {
|
|
4000
3994
|
this.checkPartitionKey(entity.partitionKey);
|
|
4001
|
-
this.
|
|
3995
|
+
this.state.pendingOperations.push(this.interceptClient.upsertEntity(entity, mode, options));
|
|
4002
3996
|
}
|
|
4003
3997
|
/**
|
|
4004
3998
|
* Submits the operations in the transaction
|
|
4005
3999
|
*/
|
|
4006
4000
|
async submitTransaction() {
|
|
4007
|
-
await Promise.all(this.
|
|
4008
|
-
const body = getTransactionHttpRequestBody(this.
|
|
4009
|
-
const headers = getTransactionHeaders(this.
|
|
4001
|
+
await Promise.all(this.state.pendingOperations);
|
|
4002
|
+
const body = getTransactionHttpRequestBody(this.state.bodyParts, this.state.transactionId, this.state.changesetId);
|
|
4003
|
+
const headers = getTransactionHeaders(this.state.transactionId);
|
|
4010
4004
|
return tracingClient.withSpan("TableTransaction.submitTransaction", {}, async (updatedOptions) => {
|
|
4011
4005
|
const request = coreRestPipeline.createPipelineRequest({
|
|
4012
4006
|
url: this.url,
|
|
@@ -4021,7 +4015,7 @@ class InternalTableTransaction {
|
|
|
4021
4015
|
});
|
|
4022
4016
|
}
|
|
4023
4017
|
checkPartitionKey(partitionKey) {
|
|
4024
|
-
if (this.
|
|
4018
|
+
if (this.state.partitionKey !== partitionKey) {
|
|
4025
4019
|
throw new Error("All operations in a transaction must target the same partitionKey");
|
|
4026
4020
|
}
|
|
4027
4021
|
}
|
|
@@ -4929,30 +4923,25 @@ class TableClient {
|
|
|
4929
4923
|
const partitionKey = actions[0][1].partitionKey;
|
|
4930
4924
|
const transactionId = Uuid.generateUuid();
|
|
4931
4925
|
const changesetId = Uuid.generateUuid();
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
this.transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.generatedClient, new TableClient(this.url, this.tableName), this.credential, this.allowInsecureConnection);
|
|
4935
|
-
}
|
|
4936
|
-
else {
|
|
4937
|
-
this.transactionClient.reset(transactionId, changesetId, partitionKey);
|
|
4938
|
-
}
|
|
4926
|
+
// Add pipeline
|
|
4927
|
+
const transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.generatedClient, new TableClient(this.url, this.tableName), this.credential, this.allowInsecureConnection);
|
|
4939
4928
|
for (const item of actions) {
|
|
4940
4929
|
const [action, entity, updateMode = "Merge", updateOptions] = item;
|
|
4941
4930
|
switch (action) {
|
|
4942
4931
|
case "create":
|
|
4943
|
-
|
|
4932
|
+
transactionClient.createEntity(entity);
|
|
4944
4933
|
break;
|
|
4945
4934
|
case "delete":
|
|
4946
|
-
|
|
4935
|
+
transactionClient.deleteEntity(entity.partitionKey, entity.rowKey);
|
|
4947
4936
|
break;
|
|
4948
4937
|
case "update":
|
|
4949
|
-
|
|
4938
|
+
transactionClient.updateEntity(entity, updateMode, updateOptions);
|
|
4950
4939
|
break;
|
|
4951
4940
|
case "upsert":
|
|
4952
|
-
|
|
4941
|
+
transactionClient.upsertEntity(entity, updateMode);
|
|
4953
4942
|
}
|
|
4954
4943
|
}
|
|
4955
|
-
return
|
|
4944
|
+
return transactionClient.submitTransaction();
|
|
4956
4945
|
}
|
|
4957
4946
|
/**
|
|
4958
4947
|
*
|