@azure/data-tables 13.0.2-alpha.20220125.1 → 13.0.2-alpha.20220217.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/CHANGELOG.md +2 -0
- package/dist/index.js +89 -39
- 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/TableServiceClient.js +3 -1
- package/dist-esm/src/TableServiceClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js +4 -22
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/dist-esm/src/secondaryEndpointPolicy.js +46 -0
- package/dist-esm/src/secondaryEndpointPolicy.js.map +1 -0
- package/dist-esm/src/utils/connectionString.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
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,17 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var coreAuth = require('@azure/core-auth');
|
|
7
|
-
var crypto = require('crypto');
|
|
8
6
|
require('@azure/core-paging');
|
|
7
|
+
var coreAuth = require('@azure/core-auth');
|
|
9
8
|
var coreXml = require('@azure/core-xml');
|
|
10
9
|
var coreClient = require('@azure/core-client');
|
|
11
10
|
var coreTracing = require('@azure/core-tracing');
|
|
12
11
|
var url$1 = require('url');
|
|
13
12
|
var logger$1 = require('@azure/logger');
|
|
13
|
+
var crypto = require('crypto');
|
|
14
14
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
15
15
|
var uuid = require('uuid');
|
|
16
16
|
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n["default"] = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
|
|
36
|
+
|
|
17
37
|
/*
|
|
18
38
|
* Copyright (c) Microsoft Corporation.
|
|
19
39
|
* Licensed under the MIT License.
|
|
@@ -34,6 +54,8 @@ var KnownResponseFormat;
|
|
|
34
54
|
KnownResponseFormat["ReturnNoContent"] = "return-no-content";
|
|
35
55
|
KnownResponseFormat["ReturnContent"] = "return-content";
|
|
36
56
|
})(KnownResponseFormat || (KnownResponseFormat = {}));
|
|
57
|
+
/** Known values of {@link GeoReplicationStatusType} that the service accepts. */
|
|
58
|
+
exports.KnownGeoReplicationStatusType = void 0;
|
|
37
59
|
(function (KnownGeoReplicationStatusType) {
|
|
38
60
|
KnownGeoReplicationStatusType["Live"] = "live";
|
|
39
61
|
KnownGeoReplicationStatusType["Bootstrap"] = "bootstrap";
|
|
@@ -739,6 +761,52 @@ function generateTableSas(tableName, credential, options = {}) {
|
|
|
739
761
|
return sas;
|
|
740
762
|
}
|
|
741
763
|
|
|
764
|
+
// Copyright (c) Microsoft Corporation.
|
|
765
|
+
// Licensed under the MIT license.
|
|
766
|
+
/**
|
|
767
|
+
* The programmatic identifier of the tablesSecondaryEndpointPolicy.
|
|
768
|
+
*/
|
|
769
|
+
const tablesSecondaryEndpointPolicyName = "tablesSecondaryEndpointPolicy";
|
|
770
|
+
const SecondaryLocationHeaderName = "tables-secondary-endpoint";
|
|
771
|
+
const SecondaryLocationAccountSuffix = "-secondary";
|
|
772
|
+
/**
|
|
773
|
+
* Policy that would replace the Primary Endpoint with the secondary endpoint
|
|
774
|
+
* when the `tables-secondary-endpoint` is set in the request
|
|
775
|
+
*/
|
|
776
|
+
const tablesSecondaryEndpointPolicy = {
|
|
777
|
+
name: tablesSecondaryEndpointPolicyName,
|
|
778
|
+
sendRequest: async (req, next) => {
|
|
779
|
+
// Only replace the URL if the SecondaryLocationHeader is set
|
|
780
|
+
if (req.headers.get(SecondaryLocationHeaderName)) {
|
|
781
|
+
// Since the header is for internal use only, clean it up.
|
|
782
|
+
req.headers.delete(SecondaryLocationHeaderName);
|
|
783
|
+
// Calculate and update the secondary url
|
|
784
|
+
req.url = getSecondaryUrlFromPrimary(req.url);
|
|
785
|
+
}
|
|
786
|
+
return next(req);
|
|
787
|
+
},
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Utility function that injects the SecondaryEndpointHeader into an operation options
|
|
791
|
+
*/
|
|
792
|
+
function injectSecondaryEndpointHeader(options) {
|
|
793
|
+
var _a;
|
|
794
|
+
const headerToInject = { [SecondaryLocationHeaderName]: "true" };
|
|
795
|
+
return Object.assign(Object.assign({}, options), { requestOptions: Object.assign(Object.assign({}, options.requestOptions), { customHeaders: Object.assign(Object.assign({}, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.customHeaders), headerToInject) }) });
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Utility function that calculates the secondary URL for a table instance given the primary URL.
|
|
799
|
+
*/
|
|
800
|
+
function getSecondaryUrlFromPrimary(primaryUrl) {
|
|
801
|
+
const parsedPrimaryUrl = new URL(primaryUrl);
|
|
802
|
+
const host = parsedPrimaryUrl.hostname.split(".");
|
|
803
|
+
if (host.length > 1) {
|
|
804
|
+
host[0] = `${host[0]}${SecondaryLocationAccountSuffix}`;
|
|
805
|
+
}
|
|
806
|
+
parsedPrimaryUrl.hostname = host.join(".");
|
|
807
|
+
return parsedPrimaryUrl.toString();
|
|
808
|
+
}
|
|
809
|
+
|
|
742
810
|
/*
|
|
743
811
|
* Copyright (c) Microsoft Corporation.
|
|
744
812
|
* Licensed under the MIT License.
|
|
@@ -2596,8 +2664,8 @@ class TableImpl {
|
|
|
2596
2664
|
}
|
|
2597
2665
|
}
|
|
2598
2666
|
// Operation Specifications
|
|
2599
|
-
const xmlSerializer =
|
|
2600
|
-
const serializer =
|
|
2667
|
+
const xmlSerializer$1 = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
|
|
2668
|
+
const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
|
|
2601
2669
|
const queryOperationSpec = {
|
|
2602
2670
|
path: "/Tables",
|
|
2603
2671
|
httpMethod: "GET",
|
|
@@ -2897,7 +2965,7 @@ const getAccessPolicyOperationSpec = {
|
|
|
2897
2965
|
accept2
|
|
2898
2966
|
],
|
|
2899
2967
|
isXML: true,
|
|
2900
|
-
serializer: xmlSerializer
|
|
2968
|
+
serializer: xmlSerializer$1
|
|
2901
2969
|
};
|
|
2902
2970
|
const setAccessPolicyOperationSpec = {
|
|
2903
2971
|
path: "/{table}",
|
|
@@ -2923,7 +2991,7 @@ const setAccessPolicyOperationSpec = {
|
|
|
2923
2991
|
isXML: true,
|
|
2924
2992
|
contentType: "application/xml; charset=utf-8",
|
|
2925
2993
|
mediaType: "xml",
|
|
2926
|
-
serializer: xmlSerializer
|
|
2994
|
+
serializer: xmlSerializer$1
|
|
2927
2995
|
};
|
|
2928
2996
|
|
|
2929
2997
|
/*
|
|
@@ -2969,7 +3037,7 @@ class ServiceImpl {
|
|
|
2969
3037
|
}
|
|
2970
3038
|
}
|
|
2971
3039
|
// Operation Specifications
|
|
2972
|
-
const xmlSerializer
|
|
3040
|
+
const xmlSerializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
|
|
2973
3041
|
const setPropertiesOperationSpec = {
|
|
2974
3042
|
path: "/",
|
|
2975
3043
|
httpMethod: "PUT",
|
|
@@ -2994,7 +3062,7 @@ const setPropertiesOperationSpec = {
|
|
|
2994
3062
|
isXML: true,
|
|
2995
3063
|
contentType: "application/xml; charset=utf-8",
|
|
2996
3064
|
mediaType: "xml",
|
|
2997
|
-
serializer: xmlSerializer
|
|
3065
|
+
serializer: xmlSerializer
|
|
2998
3066
|
};
|
|
2999
3067
|
const getPropertiesOperationSpec = {
|
|
3000
3068
|
path: "/",
|
|
@@ -3017,7 +3085,7 @@ const getPropertiesOperationSpec = {
|
|
|
3017
3085
|
accept2
|
|
3018
3086
|
],
|
|
3019
3087
|
isXML: true,
|
|
3020
|
-
serializer: xmlSerializer
|
|
3088
|
+
serializer: xmlSerializer
|
|
3021
3089
|
};
|
|
3022
3090
|
const getStatisticsOperationSpec = {
|
|
3023
3091
|
path: "/",
|
|
@@ -3040,7 +3108,7 @@ const getStatisticsOperationSpec = {
|
|
|
3040
3108
|
accept2
|
|
3041
3109
|
],
|
|
3042
3110
|
isXML: true,
|
|
3043
|
-
serializer: xmlSerializer
|
|
3111
|
+
serializer: xmlSerializer
|
|
3044
3112
|
};
|
|
3045
3113
|
|
|
3046
3114
|
/*
|
|
@@ -3051,7 +3119,7 @@ const getStatisticsOperationSpec = {
|
|
|
3051
3119
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
3052
3120
|
*/
|
|
3053
3121
|
/** @internal */
|
|
3054
|
-
class GeneratedClientContext extends
|
|
3122
|
+
class GeneratedClientContext extends coreClient__namespace.ServiceClient {
|
|
3055
3123
|
/**
|
|
3056
3124
|
* Initializes a new instance of the GeneratedClientContext class.
|
|
3057
3125
|
* @param url The URL of the service account or table that is the target of the desired operation.
|
|
@@ -3440,6 +3508,7 @@ class TableServiceClient {
|
|
|
3440
3508
|
},
|
|
3441
3509
|
}), (coreAuth.isTokenCredential(credential) && { credential, credentialScopes: STORAGE_SCOPE }));
|
|
3442
3510
|
const client = new GeneratedClient(this.url, internalPipelineOptions);
|
|
3511
|
+
client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);
|
|
3443
3512
|
if (coreAuth.isNamedKeyCredential(credential)) {
|
|
3444
3513
|
client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));
|
|
3445
3514
|
}
|
|
@@ -3458,7 +3527,7 @@ class TableServiceClient {
|
|
|
3458
3527
|
async getStatistics(options = {}) {
|
|
3459
3528
|
const { span, updatedOptions } = createSpan("TableServiceClient-getStatistics", options);
|
|
3460
3529
|
try {
|
|
3461
|
-
return await this.service.getStatistics(updatedOptions);
|
|
3530
|
+
return await this.service.getStatistics(injectSecondaryEndpointHeader(updatedOptions));
|
|
3462
3531
|
}
|
|
3463
3532
|
catch (e) {
|
|
3464
3533
|
span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message });
|
|
@@ -3852,9 +3921,8 @@ class InternalTableTransaction {
|
|
|
3852
3921
|
* @param partitionKey - partition key
|
|
3853
3922
|
* @param credential - credential to authenticate the transaction request
|
|
3854
3923
|
*/
|
|
3855
|
-
constructor(url, partitionKey, transactionId, changesetId,
|
|
3856
|
-
this.
|
|
3857
|
-
this.credential = credential;
|
|
3924
|
+
constructor(url, partitionKey, transactionId, changesetId, client, interceptClient, credential, allowInsecureConnection = false) {
|
|
3925
|
+
this.client = client;
|
|
3858
3926
|
this.url = url;
|
|
3859
3927
|
this.interceptClient = interceptClient;
|
|
3860
3928
|
this.allowInsecureConnection = allowInsecureConnection;
|
|
@@ -3948,12 +4016,6 @@ class InternalTableTransaction {
|
|
|
3948
4016
|
async submitTransaction() {
|
|
3949
4017
|
await Promise.all(this.resetableState.pendingOperations);
|
|
3950
4018
|
const body = getTransactionHttpRequestBody(this.resetableState.bodyParts, this.resetableState.transactionId, this.resetableState.changesetId);
|
|
3951
|
-
const options = this.clientOptions;
|
|
3952
|
-
if (coreAuth.isTokenCredential(this.credential)) {
|
|
3953
|
-
options.credentialScopes = STORAGE_SCOPE;
|
|
3954
|
-
options.credential = this.credential;
|
|
3955
|
-
}
|
|
3956
|
-
const client = new coreClient.ServiceClient(options);
|
|
3957
4019
|
const headers = getTransactionHeaders(this.resetableState.transactionId);
|
|
3958
4020
|
const { span, updatedOptions } = createSpan("TableTransaction-submitTransaction", {});
|
|
3959
4021
|
const request = coreRestPipeline.createPipelineRequest({
|
|
@@ -3964,15 +4026,8 @@ class InternalTableTransaction {
|
|
|
3964
4026
|
tracingOptions: updatedOptions.tracingOptions,
|
|
3965
4027
|
allowInsecureConnection: this.allowInsecureConnection,
|
|
3966
4028
|
});
|
|
3967
|
-
if (coreAuth.isNamedKeyCredential(this.credential)) {
|
|
3968
|
-
const authHeader = getAuthorizationHeader(request, this.credential);
|
|
3969
|
-
request.headers.set("Authorization", authHeader);
|
|
3970
|
-
}
|
|
3971
|
-
else if (coreAuth.isSASCredential(this.credential)) {
|
|
3972
|
-
signURLWithSAS(request, this.credential);
|
|
3973
|
-
}
|
|
3974
4029
|
try {
|
|
3975
|
-
const rawTransactionResponse = await client.sendRequest(request);
|
|
4030
|
+
const rawTransactionResponse = await this.client.sendRequest(request);
|
|
3976
4031
|
return parseTransactionResponse(rawTransactionResponse);
|
|
3977
4032
|
}
|
|
3978
4033
|
catch (error) {
|
|
@@ -4416,6 +4471,7 @@ class TableClient {
|
|
|
4416
4471
|
if (isCosmosEndpoint(this.url)) {
|
|
4417
4472
|
generatedClient.pipeline.addPolicy(cosmosPatchPolicy());
|
|
4418
4473
|
}
|
|
4474
|
+
this.generatedClient = generatedClient;
|
|
4419
4475
|
this.table = generatedClient.table;
|
|
4420
4476
|
this.pipeline = generatedClient.pipeline;
|
|
4421
4477
|
}
|
|
@@ -4952,7 +5008,7 @@ class TableClient {
|
|
|
4952
5008
|
const changesetId = Uuid.generateUuid();
|
|
4953
5009
|
if (!this.transactionClient) {
|
|
4954
5010
|
// Add pipeline
|
|
4955
|
-
this.transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.
|
|
5011
|
+
this.transactionClient = new InternalTableTransaction(this.url, partitionKey, transactionId, changesetId, this.generatedClient, new TableClient(this.url, this.tableName), this.credential, this.allowInsecureConnection);
|
|
4956
5012
|
}
|
|
4957
5013
|
else {
|
|
4958
5014
|
this.transactionClient.reset(transactionId, changesetId, partitionKey);
|
|
@@ -5003,21 +5059,15 @@ class TableClient {
|
|
|
5003
5059
|
|
|
5004
5060
|
Object.defineProperty(exports, 'AzureNamedKeyCredential', {
|
|
5005
5061
|
enumerable: true,
|
|
5006
|
-
get: function () {
|
|
5007
|
-
return coreAuth.AzureNamedKeyCredential;
|
|
5008
|
-
}
|
|
5062
|
+
get: function () { return coreAuth.AzureNamedKeyCredential; }
|
|
5009
5063
|
});
|
|
5010
5064
|
Object.defineProperty(exports, 'AzureSASCredential', {
|
|
5011
5065
|
enumerable: true,
|
|
5012
|
-
get: function () {
|
|
5013
|
-
return coreAuth.AzureSASCredential;
|
|
5014
|
-
}
|
|
5066
|
+
get: function () { return coreAuth.AzureSASCredential; }
|
|
5015
5067
|
});
|
|
5016
5068
|
Object.defineProperty(exports, 'RestError', {
|
|
5017
5069
|
enumerable: true,
|
|
5018
|
-
get: function () {
|
|
5019
|
-
return coreRestPipeline.RestError;
|
|
5020
|
-
}
|
|
5070
|
+
get: function () { return coreRestPipeline.RestError; }
|
|
5021
5071
|
});
|
|
5022
5072
|
exports.TableClient = TableClient;
|
|
5023
5073
|
exports.TableServiceClient = TableServiceClient;
|