@azure/data-tables 13.0.1-alpha.20211112.1 → 13.0.1-alpha.20211217.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 +5 -0
- package/README.md +39 -8
- package/dist/index.js +309 -284
- package/dist/index.js.map +1 -1
- package/dist-esm/src/TableClient.js +15 -20
- package/dist-esm/src/TableClient.js.map +1 -1
- package/dist-esm/src/TablePolicies.js +2 -2
- package/dist-esm/src/TablePolicies.js.map +1 -1
- package/dist-esm/src/TableServiceClient.js +9 -14
- package/dist-esm/src/TableServiceClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js +9 -9
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/dist-esm/src/logger.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/sas/accountSasSignatureValues.js +5 -5
- package/dist-esm/src/sas/accountSasSignatureValues.js.map +1 -1
- package/dist-esm/src/sas/generateAccountSas.js +1 -1
- package/dist-esm/src/sas/generateAccountSas.js.map +1 -1
- package/dist-esm/src/sas/generateTableSas.js +14 -8
- package/dist-esm/src/sas/generateTableSas.js.map +1 -1
- package/dist-esm/src/sas/sasQueryParameters.js +1 -1
- package/dist-esm/src/sas/sasQueryParameters.js.map +1 -1
- package/dist-esm/src/sas/tableSasSignatureValues.js +9 -9
- package/dist-esm/src/sas/tableSasSignatureValues.js.map +1 -1
- package/dist-esm/src/serialization.js +2 -2
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/tablesNamedCredentialPolicy.js.map +1 -1
- package/dist-esm/src/tablesSASTokenPolicy.js.map +1 -1
- package/dist-esm/src/utils/accountConnectionString.browser.js.map +1 -1
- package/dist-esm/src/utils/accountConnectionString.js.map +1 -1
- package/dist-esm/src/utils/connectionString.js.map +1 -1
- package/dist-esm/src/utils/continuationToken.js +1 -1
- package/dist-esm/src/utils/continuationToken.js.map +1 -1
- package/dist-esm/src/utils/errorHelpers.js +36 -0
- package/dist-esm/src/utils/errorHelpers.js.map +1 -0
- package/dist-esm/src/utils/internalModels.js.map +1 -1
- package/dist-esm/src/utils/isCredential.js.map +1 -1
- package/package.json +7 -9
- package/types/3.1/data-tables.d.ts +4 -3
- package/types/latest/data-tables.d.ts +4 -3
package/dist/index.js
CHANGED
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var coreAuth = require('@azure/core-auth');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
|
+
require('@azure/core-paging');
|
|
9
|
+
var coreXml = require('@azure/core-xml');
|
|
8
10
|
var coreClient = require('@azure/core-client');
|
|
11
|
+
var coreTracing = require('@azure/core-tracing');
|
|
9
12
|
var url$1 = require('url');
|
|
10
|
-
require('@azure/core-paging');
|
|
11
13
|
var logger$1 = require('@azure/logger');
|
|
12
|
-
var coreTracing = require('@azure/core-tracing');
|
|
13
|
-
var coreXml = require('@azure/core-xml');
|
|
14
14
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
15
15
|
var uuid = require('uuid');
|
|
16
16
|
|
|
@@ -162,113 +162,21 @@ function accountSasServicesToString(services = { table: true }) {
|
|
|
162
162
|
return servicesString.join("");
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
// Copyright (c) Microsoft Corporation.
|
|
166
|
-
function computeHMACSHA256(stringToSign, accountKey) {
|
|
167
|
-
const key = Buffer.from(accountKey, "base64");
|
|
168
|
-
return crypto.createHmac("sha256", key)
|
|
169
|
-
.update(stringToSign, "utf8")
|
|
170
|
-
.digest("base64");
|
|
171
|
-
}
|
|
172
|
-
|
|
173
165
|
// Copyright (c) Microsoft Corporation.
|
|
174
166
|
// Licensed under the MIT license.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
const TablesLoggingAllowedHeaderNames = [
|
|
190
|
-
"Access-Control-Allow-Origin",
|
|
191
|
-
"Cache-Control",
|
|
192
|
-
"Content-Length",
|
|
193
|
-
"Content-Type",
|
|
194
|
-
"Date",
|
|
195
|
-
"Prefer",
|
|
196
|
-
"Preference-Applied",
|
|
197
|
-
"Request-Id",
|
|
198
|
-
"traceparent",
|
|
199
|
-
"Transfer-Encoding",
|
|
200
|
-
"User-Agent",
|
|
201
|
-
"x-ms-client-request-id",
|
|
202
|
-
"x-ms-user-agent",
|
|
203
|
-
"x-ms-date",
|
|
204
|
-
"x-ms-error-code",
|
|
205
|
-
"x-ms-request-id",
|
|
206
|
-
"x-ms-return-client-request-id",
|
|
207
|
-
"x-ms-version",
|
|
208
|
-
"Accept-Ranges",
|
|
209
|
-
"Accept",
|
|
210
|
-
"Content-Disposition",
|
|
211
|
-
"Content-Encoding",
|
|
212
|
-
"Content-Language",
|
|
213
|
-
"Content-MD5",
|
|
214
|
-
"Content-Range",
|
|
215
|
-
"ETag",
|
|
216
|
-
"Last-Modified",
|
|
217
|
-
"Server",
|
|
218
|
-
"Vary",
|
|
219
|
-
"x-ms-content-crc64",
|
|
220
|
-
"x-ms-copy-action",
|
|
221
|
-
"x-ms-copy-completion-time",
|
|
222
|
-
"x-ms-copy-id",
|
|
223
|
-
"x-ms-copy-progress",
|
|
224
|
-
"x-ms-copy-status",
|
|
225
|
-
"x-ms-continuation-NextTableName",
|
|
226
|
-
"x-ms-continuation-NextPartitionKey",
|
|
227
|
-
"x-ms-continuation-NextRowKey",
|
|
228
|
-
"x-ms-has-immutability-policy",
|
|
229
|
-
"x-ms-has-legal-hold",
|
|
230
|
-
"x-ms-lease-state",
|
|
231
|
-
"x-ms-lease-status",
|
|
232
|
-
"x-ms-range",
|
|
233
|
-
"x-ms-request-server-encrypted",
|
|
234
|
-
"x-ms-server-encrypted",
|
|
235
|
-
"x-ms-snapshot",
|
|
236
|
-
"x-ms-source-range",
|
|
237
|
-
"If-Match",
|
|
238
|
-
"If-Modified-Since",
|
|
239
|
-
"If-None-Match",
|
|
240
|
-
"If-Unmodified-Since",
|
|
241
|
-
"x-ms-access-tier",
|
|
242
|
-
"x-ms-access-tier-change-time",
|
|
243
|
-
"x-ms-access-tier-inferred",
|
|
244
|
-
"x-ms-account-kind",
|
|
245
|
-
"x-ms-archive-status",
|
|
246
|
-
"x-ms-copy-destination-snapshot",
|
|
247
|
-
"x-ms-creation-time",
|
|
248
|
-
"x-ms-default-encryption-scope",
|
|
249
|
-
"x-ms-delete-type-permanent",
|
|
250
|
-
"x-ms-deny-encryption-scope-override",
|
|
251
|
-
"x-ms-encryption-algorithm",
|
|
252
|
-
"x-ms-incremental-copy",
|
|
253
|
-
"x-ms-lease-action",
|
|
254
|
-
"x-ms-lease-break-period",
|
|
255
|
-
"x-ms-lease-duration",
|
|
256
|
-
"x-ms-lease-id",
|
|
257
|
-
"x-ms-lease-time",
|
|
258
|
-
"x-ms-page-write",
|
|
259
|
-
"x-ms-proposed-lease-id",
|
|
260
|
-
"x-ms-range-get-content-md5",
|
|
261
|
-
"x-ms-rehydrate-priority",
|
|
262
|
-
"x-ms-sequence-number-action",
|
|
263
|
-
"x-ms-sku-name",
|
|
264
|
-
"x-ms-source-content-md5",
|
|
265
|
-
"x-ms-source-if-match",
|
|
266
|
-
"x-ms-source-if-modified-since",
|
|
267
|
-
"x-ms-source-if-none-match",
|
|
268
|
-
"x-ms-source-if-unmodified-since",
|
|
269
|
-
"x-ms-tag-count",
|
|
270
|
-
"x-ms-encryption-key-sha256"
|
|
271
|
-
];
|
|
167
|
+
/**
|
|
168
|
+
* Generate SasIPRange format string. For example:
|
|
169
|
+
*
|
|
170
|
+
* "8.8.8.8" or "1.1.1.1-255.255.255.255"
|
|
171
|
+
*
|
|
172
|
+
* @param ipRange -
|
|
173
|
+
*/
|
|
174
|
+
function ipRangeToString(ipRange) {
|
|
175
|
+
if (!ipRange) {
|
|
176
|
+
return "";
|
|
177
|
+
}
|
|
178
|
+
return ipRange.end ? `${ipRange.start}-${ipRange.end}` : ipRange.start;
|
|
179
|
+
}
|
|
272
180
|
|
|
273
181
|
// Copyright (c) Microsoft Corporation.
|
|
274
182
|
// Licensed under the MIT license.
|
|
@@ -288,69 +196,6 @@ function truncatedISO8061Date(date, withMilliseconds = true) {
|
|
|
288
196
|
: dateString.substring(0, dateString.length - 5) + "Z";
|
|
289
197
|
}
|
|
290
198
|
|
|
291
|
-
// Copyright (c) Microsoft Corporation.
|
|
292
|
-
// Licensed under the MIT license.
|
|
293
|
-
/**
|
|
294
|
-
* Creates an {@link accountSasResourceTypesFromString} from the specified resource types string. This method will throw an
|
|
295
|
-
* Error if it encounters a character that does not correspond to a valid resource type.
|
|
296
|
-
*
|
|
297
|
-
* @param resourceTypes -
|
|
298
|
-
*/
|
|
299
|
-
function accountSasResourceTypesFromString(resourceTypes) {
|
|
300
|
-
const accountSasResourceTypes = {};
|
|
301
|
-
for (const c of resourceTypes) {
|
|
302
|
-
switch (c) {
|
|
303
|
-
case "s":
|
|
304
|
-
accountSasResourceTypes.service = true;
|
|
305
|
-
break;
|
|
306
|
-
case "c":
|
|
307
|
-
accountSasResourceTypes.container = true;
|
|
308
|
-
break;
|
|
309
|
-
case "o":
|
|
310
|
-
accountSasResourceTypes.object = true;
|
|
311
|
-
break;
|
|
312
|
-
default:
|
|
313
|
-
throw new RangeError(`Invalid resource type: ${c}`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return accountSasResourceTypes;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Converts the given resource types to a string.
|
|
320
|
-
*
|
|
321
|
-
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas
|
|
322
|
-
*
|
|
323
|
-
*/
|
|
324
|
-
function accountSasResourceTypesToString(resourceTypes) {
|
|
325
|
-
const resourceTypesString = [];
|
|
326
|
-
if (resourceTypes.service) {
|
|
327
|
-
resourceTypesString.push("s");
|
|
328
|
-
}
|
|
329
|
-
if (resourceTypes.container) {
|
|
330
|
-
resourceTypesString.push("c");
|
|
331
|
-
}
|
|
332
|
-
if (resourceTypes.object) {
|
|
333
|
-
resourceTypesString.push("o");
|
|
334
|
-
}
|
|
335
|
-
return resourceTypesString.join("");
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Copyright (c) Microsoft Corporation.
|
|
339
|
-
// Licensed under the MIT license.
|
|
340
|
-
/**
|
|
341
|
-
* Generate SasIPRange format string. For example:
|
|
342
|
-
*
|
|
343
|
-
* "8.8.8.8" or "1.1.1.1-255.255.255.255"
|
|
344
|
-
*
|
|
345
|
-
* @param ipRange -
|
|
346
|
-
*/
|
|
347
|
-
function ipRangeToString(ipRange) {
|
|
348
|
-
if (!ipRange) {
|
|
349
|
-
return "";
|
|
350
|
-
}
|
|
351
|
-
return ipRange.end ? `${ipRange.start}-${ipRange.end}` : ipRange.start;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
199
|
// Copyright (c) Microsoft Corporation.
|
|
355
200
|
/**
|
|
356
201
|
* Represents the components that make up an Azure SAS' query parameters. This type is not constructed directly
|
|
@@ -521,6 +366,161 @@ class SasQueryParameters {
|
|
|
521
366
|
}
|
|
522
367
|
}
|
|
523
368
|
|
|
369
|
+
// Copyright (c) Microsoft Corporation.
|
|
370
|
+
// Licensed under the MIT license.
|
|
371
|
+
/**
|
|
372
|
+
* Creates an {@link accountSasResourceTypesFromString} from the specified resource types string. This method will throw an
|
|
373
|
+
* Error if it encounters a character that does not correspond to a valid resource type.
|
|
374
|
+
*
|
|
375
|
+
* @param resourceTypes -
|
|
376
|
+
*/
|
|
377
|
+
function accountSasResourceTypesFromString(resourceTypes) {
|
|
378
|
+
const accountSasResourceTypes = {};
|
|
379
|
+
for (const c of resourceTypes) {
|
|
380
|
+
switch (c) {
|
|
381
|
+
case "s":
|
|
382
|
+
accountSasResourceTypes.service = true;
|
|
383
|
+
break;
|
|
384
|
+
case "c":
|
|
385
|
+
accountSasResourceTypes.container = true;
|
|
386
|
+
break;
|
|
387
|
+
case "o":
|
|
388
|
+
accountSasResourceTypes.object = true;
|
|
389
|
+
break;
|
|
390
|
+
default:
|
|
391
|
+
throw new RangeError(`Invalid resource type: ${c}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return accountSasResourceTypes;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Converts the given resource types to a string.
|
|
398
|
+
*
|
|
399
|
+
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas
|
|
400
|
+
*
|
|
401
|
+
*/
|
|
402
|
+
function accountSasResourceTypesToString(resourceTypes) {
|
|
403
|
+
const resourceTypesString = [];
|
|
404
|
+
if (resourceTypes.service) {
|
|
405
|
+
resourceTypesString.push("s");
|
|
406
|
+
}
|
|
407
|
+
if (resourceTypes.container) {
|
|
408
|
+
resourceTypesString.push("c");
|
|
409
|
+
}
|
|
410
|
+
if (resourceTypes.object) {
|
|
411
|
+
resourceTypesString.push("o");
|
|
412
|
+
}
|
|
413
|
+
return resourceTypesString.join("");
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Copyright (c) Microsoft Corporation.
|
|
417
|
+
// Licensed under the MIT license.
|
|
418
|
+
const SERVICE_VERSION = "2019-02-02";
|
|
419
|
+
const TRANSACTION_HTTP_VERSION_1_1 = "HTTP/1.1";
|
|
420
|
+
const TRANSACTION_HTTP_LINE_ENDING = "\r\n";
|
|
421
|
+
const STORAGE_SCOPE = "https://storage.azure.com/.default";
|
|
422
|
+
const HeaderConstants = {
|
|
423
|
+
AUTHORIZATION: "authorization",
|
|
424
|
+
CONTENT_LENGTH: "content-length",
|
|
425
|
+
CONTENT_MD5: "content-md5",
|
|
426
|
+
CONTENT_TYPE: "content-type",
|
|
427
|
+
CONTENT_TRANSFER_ENCODING: "content-transfer-encoding",
|
|
428
|
+
DATE: "date",
|
|
429
|
+
X_MS_DATE: "x-ms-date",
|
|
430
|
+
X_MS_VERSION: "x-ms-version"
|
|
431
|
+
};
|
|
432
|
+
const TablesLoggingAllowedHeaderNames = [
|
|
433
|
+
"Access-Control-Allow-Origin",
|
|
434
|
+
"Cache-Control",
|
|
435
|
+
"Content-Length",
|
|
436
|
+
"Content-Type",
|
|
437
|
+
"Date",
|
|
438
|
+
"Prefer",
|
|
439
|
+
"Preference-Applied",
|
|
440
|
+
"Request-Id",
|
|
441
|
+
"traceparent",
|
|
442
|
+
"Transfer-Encoding",
|
|
443
|
+
"User-Agent",
|
|
444
|
+
"x-ms-client-request-id",
|
|
445
|
+
"x-ms-user-agent",
|
|
446
|
+
"x-ms-date",
|
|
447
|
+
"x-ms-error-code",
|
|
448
|
+
"x-ms-request-id",
|
|
449
|
+
"x-ms-return-client-request-id",
|
|
450
|
+
"x-ms-version",
|
|
451
|
+
"Accept-Ranges",
|
|
452
|
+
"Accept",
|
|
453
|
+
"Content-Disposition",
|
|
454
|
+
"Content-Encoding",
|
|
455
|
+
"Content-Language",
|
|
456
|
+
"Content-MD5",
|
|
457
|
+
"Content-Range",
|
|
458
|
+
"ETag",
|
|
459
|
+
"Last-Modified",
|
|
460
|
+
"Server",
|
|
461
|
+
"Vary",
|
|
462
|
+
"x-ms-content-crc64",
|
|
463
|
+
"x-ms-copy-action",
|
|
464
|
+
"x-ms-copy-completion-time",
|
|
465
|
+
"x-ms-copy-id",
|
|
466
|
+
"x-ms-copy-progress",
|
|
467
|
+
"x-ms-copy-status",
|
|
468
|
+
"x-ms-continuation-NextTableName",
|
|
469
|
+
"x-ms-continuation-NextPartitionKey",
|
|
470
|
+
"x-ms-continuation-NextRowKey",
|
|
471
|
+
"x-ms-has-immutability-policy",
|
|
472
|
+
"x-ms-has-legal-hold",
|
|
473
|
+
"x-ms-lease-state",
|
|
474
|
+
"x-ms-lease-status",
|
|
475
|
+
"x-ms-range",
|
|
476
|
+
"x-ms-request-server-encrypted",
|
|
477
|
+
"x-ms-server-encrypted",
|
|
478
|
+
"x-ms-snapshot",
|
|
479
|
+
"x-ms-source-range",
|
|
480
|
+
"If-Match",
|
|
481
|
+
"If-Modified-Since",
|
|
482
|
+
"If-None-Match",
|
|
483
|
+
"If-Unmodified-Since",
|
|
484
|
+
"x-ms-access-tier",
|
|
485
|
+
"x-ms-access-tier-change-time",
|
|
486
|
+
"x-ms-access-tier-inferred",
|
|
487
|
+
"x-ms-account-kind",
|
|
488
|
+
"x-ms-archive-status",
|
|
489
|
+
"x-ms-copy-destination-snapshot",
|
|
490
|
+
"x-ms-creation-time",
|
|
491
|
+
"x-ms-default-encryption-scope",
|
|
492
|
+
"x-ms-delete-type-permanent",
|
|
493
|
+
"x-ms-deny-encryption-scope-override",
|
|
494
|
+
"x-ms-encryption-algorithm",
|
|
495
|
+
"x-ms-incremental-copy",
|
|
496
|
+
"x-ms-lease-action",
|
|
497
|
+
"x-ms-lease-break-period",
|
|
498
|
+
"x-ms-lease-duration",
|
|
499
|
+
"x-ms-lease-id",
|
|
500
|
+
"x-ms-lease-time",
|
|
501
|
+
"x-ms-page-write",
|
|
502
|
+
"x-ms-proposed-lease-id",
|
|
503
|
+
"x-ms-range-get-content-md5",
|
|
504
|
+
"x-ms-rehydrate-priority",
|
|
505
|
+
"x-ms-sequence-number-action",
|
|
506
|
+
"x-ms-sku-name",
|
|
507
|
+
"x-ms-source-content-md5",
|
|
508
|
+
"x-ms-source-if-match",
|
|
509
|
+
"x-ms-source-if-modified-since",
|
|
510
|
+
"x-ms-source-if-none-match",
|
|
511
|
+
"x-ms-source-if-unmodified-since",
|
|
512
|
+
"x-ms-tag-count",
|
|
513
|
+
"x-ms-encryption-key-sha256"
|
|
514
|
+
];
|
|
515
|
+
|
|
516
|
+
// Copyright (c) Microsoft Corporation.
|
|
517
|
+
function computeHMACSHA256(stringToSign, accountKey) {
|
|
518
|
+
const key = Buffer.from(accountKey, "base64");
|
|
519
|
+
return crypto.createHmac("sha256", key)
|
|
520
|
+
.update(stringToSign, "utf8")
|
|
521
|
+
.digest("base64");
|
|
522
|
+
}
|
|
523
|
+
|
|
524
524
|
// Copyright (c) Microsoft Corporation.
|
|
525
525
|
/**
|
|
526
526
|
* ONLY AVAILABLE IN NODE.JS RUNTIME.
|
|
@@ -653,12 +653,7 @@ function tableSasPermissionsToString(permissions) {
|
|
|
653
653
|
*
|
|
654
654
|
* Creates an instance of SASQueryParameters.
|
|
655
655
|
*
|
|
656
|
-
*
|
|
657
|
-
* set corresponding properties directly, such as permissions, startsOn and identifier.
|
|
658
|
-
*
|
|
659
|
-
* WARNING: When identifier is not provided, permissions and expiresOn are required.
|
|
660
|
-
* You MUST assign value to identifier or expiresOn & permissions manually if you initial with
|
|
661
|
-
* this constructor.
|
|
656
|
+
* **Note**: When identifier is not provided, permissions has a default value of "read" and expiresOn of one hour from the time the token is generated.
|
|
662
657
|
*/
|
|
663
658
|
function generateTableSasQueryParameters(tableName, credential, tableSasSignatureValues) {
|
|
664
659
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -726,16 +721,23 @@ function getCanonicalName(accountName, tableName) {
|
|
|
726
721
|
* @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
|
|
727
722
|
*/
|
|
728
723
|
function generateTableSas(tableName, credential, options = {}) {
|
|
729
|
-
|
|
724
|
+
let { expiresOn, permissions } = options;
|
|
730
725
|
if (!coreAuth.isNamedKeyCredential(credential)) {
|
|
731
726
|
throw RangeError("Can only generate the account SAS when the client is initialized with a shared key credential");
|
|
732
727
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
728
|
+
// expiresOn and permissions are optional if an identifier is provided
|
|
729
|
+
// set defaults when no identifier and no values were provided
|
|
730
|
+
if (!options.identifier) {
|
|
731
|
+
if (!permissions) {
|
|
732
|
+
permissions = tableSasPermissionsFromString("r");
|
|
733
|
+
}
|
|
734
|
+
if (expiresOn === undefined) {
|
|
735
|
+
const now = new Date();
|
|
736
|
+
expiresOn = new Date(now.getTime() + 3600 * 1000);
|
|
737
|
+
}
|
|
737
738
|
}
|
|
738
|
-
const sas = generateTableSasQueryParameters(tableName, credential, Object.assign({
|
|
739
|
+
const sas = generateTableSasQueryParameters(tableName, credential, Object.assign(Object.assign({}, options), { expiresOn,
|
|
740
|
+
permissions })).toString();
|
|
739
741
|
return sas;
|
|
740
742
|
}
|
|
741
743
|
|
|
@@ -3104,6 +3106,16 @@ class GeneratedClient extends GeneratedClientContext {
|
|
|
3104
3106
|
}
|
|
3105
3107
|
}
|
|
3106
3108
|
|
|
3109
|
+
// Copyright (c) Microsoft Corporation.
|
|
3110
|
+
/**
|
|
3111
|
+
* Creates a span using the global tracer.
|
|
3112
|
+
* @internal
|
|
3113
|
+
*/
|
|
3114
|
+
const createSpan = coreTracing.createSpanFunction({
|
|
3115
|
+
packagePrefix: "Azure.Data.Tables",
|
|
3116
|
+
namespace: "Microsoft.Data.Tables"
|
|
3117
|
+
});
|
|
3118
|
+
|
|
3107
3119
|
// Copyright (c) Microsoft Corporation.
|
|
3108
3120
|
/**
|
|
3109
3121
|
* Gets client parameters from an Account Connection String
|
|
@@ -3276,20 +3288,49 @@ function getAccountNameFromUrl(url) {
|
|
|
3276
3288
|
}
|
|
3277
3289
|
|
|
3278
3290
|
// Copyright (c) Microsoft Corporation.
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3291
|
+
function handleTableAlreadyExists(error, options = {}) {
|
|
3292
|
+
var _a, _b, _c;
|
|
3293
|
+
const responseError = getErrorResponse(error);
|
|
3294
|
+
if (responseError &&
|
|
3295
|
+
responseError.status === 409 &&
|
|
3296
|
+
((_a = responseError.parsedBody.odataError) === null || _a === void 0 ? void 0 : _a.code) === "TableAlreadyExists") {
|
|
3297
|
+
(_b = options.logger) === null || _b === void 0 ? void 0 : _b.info(`Table ${options.tableName} already Exists`);
|
|
3298
|
+
if (options.onResponse) {
|
|
3299
|
+
options.onResponse(responseError, {});
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
else {
|
|
3303
|
+
options === null || options === void 0 ? void 0 : options.span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: (_c = error) === null || _c === void 0 ? void 0 : _c.message });
|
|
3304
|
+
throw error;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
function getErrorResponse(error) {
|
|
3308
|
+
if (!isRestError(error)) {
|
|
3309
|
+
return undefined;
|
|
3310
|
+
}
|
|
3311
|
+
const errorResponse = error.response;
|
|
3312
|
+
if (!errorResponse || !isTableServiceErrorResponse(errorResponse.parsedBody)) {
|
|
3313
|
+
return undefined;
|
|
3314
|
+
}
|
|
3315
|
+
return errorResponse;
|
|
3316
|
+
}
|
|
3317
|
+
function isRestError(error) {
|
|
3318
|
+
return error.name === "RestError";
|
|
3319
|
+
}
|
|
3320
|
+
function isTableServiceErrorResponse(errorResponseBody) {
|
|
3321
|
+
return Boolean(errorResponseBody === null || errorResponseBody === void 0 ? void 0 : errorResponseBody.odataError);
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
// Copyright (c) Microsoft Corporation.
|
|
3325
|
+
function isCredential(credential) {
|
|
3326
|
+
return (coreAuth.isSASCredential(credential) || coreAuth.isNamedKeyCredential(credential) || coreAuth.isTokenCredential(credential));
|
|
3327
|
+
}
|
|
3283
3328
|
|
|
3284
3329
|
// Copyright (c) Microsoft Corporation.
|
|
3285
3330
|
/**
|
|
3286
|
-
*
|
|
3287
|
-
* @internal
|
|
3331
|
+
* The \@azure/logger configuration for this package.
|
|
3288
3332
|
*/
|
|
3289
|
-
const
|
|
3290
|
-
packagePrefix: "Azure.Data.Tables",
|
|
3291
|
-
namespace: "Microsoft.Data.Tables"
|
|
3292
|
-
});
|
|
3333
|
+
const logger = logger$1.createClientLogger("data-tables");
|
|
3293
3334
|
|
|
3294
3335
|
// Copyright (c) Microsoft Corporation.
|
|
3295
3336
|
/**
|
|
@@ -3351,11 +3392,6 @@ function getCanonicalizedResourceString(request, credential) {
|
|
|
3351
3392
|
return canonicalizedResourceString;
|
|
3352
3393
|
}
|
|
3353
3394
|
|
|
3354
|
-
// Copyright (c) Microsoft Corporation.
|
|
3355
|
-
function isCredential(credential) {
|
|
3356
|
-
return (coreAuth.isSASCredential(credential) || coreAuth.isNamedKeyCredential(credential) || coreAuth.isTokenCredential(credential));
|
|
3357
|
-
}
|
|
3358
|
-
|
|
3359
3395
|
// Copyright (c) Microsoft Corporation.
|
|
3360
3396
|
/**
|
|
3361
3397
|
* The programmatic identifier of the tablesSASTokenPolicy.
|
|
@@ -3479,16 +3515,10 @@ class TableServiceClient {
|
|
|
3479
3515
|
async createTable(name, options = {}) {
|
|
3480
3516
|
const { span, updatedOptions } = createSpan("TableServiceClient-createTable", options);
|
|
3481
3517
|
try {
|
|
3482
|
-
await this.table.create({ name }, Object.assign(
|
|
3518
|
+
await this.table.create({ name }, Object.assign({}, updatedOptions));
|
|
3483
3519
|
}
|
|
3484
3520
|
catch (e) {
|
|
3485
|
-
|
|
3486
|
-
logger.info("TableServiceClient-createTable: Table Already Exists");
|
|
3487
|
-
}
|
|
3488
|
-
else {
|
|
3489
|
-
span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message });
|
|
3490
|
-
throw e;
|
|
3491
|
-
}
|
|
3521
|
+
handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { span, logger, tableName: name }));
|
|
3492
3522
|
}
|
|
3493
3523
|
finally {
|
|
3494
3524
|
span.end();
|
|
@@ -3617,34 +3647,6 @@ class TableServiceClient {
|
|
|
3617
3647
|
}
|
|
3618
3648
|
}
|
|
3619
3649
|
|
|
3620
|
-
// Copyright (c) Microsoft Corporation.
|
|
3621
|
-
// Licensed under the MIT license.
|
|
3622
|
-
/**
|
|
3623
|
-
* @internal
|
|
3624
|
-
* Builds an object with the required headers for a Transaction request. For both Node and Browser
|
|
3625
|
-
*/
|
|
3626
|
-
function getBaseTransactionHeaders(transactionGuid) {
|
|
3627
|
-
return {
|
|
3628
|
-
accept: "application/json",
|
|
3629
|
-
"x-ms-version": "2019-02-02",
|
|
3630
|
-
DataServiceVersion: "3.0;",
|
|
3631
|
-
MaxDataServiceVersion: "3.0;NetFx",
|
|
3632
|
-
"Content-Type": `multipart/mixed; boundary=batch_${transactionGuid}`
|
|
3633
|
-
};
|
|
3634
|
-
}
|
|
3635
|
-
|
|
3636
|
-
// Copyright (c) Microsoft Corporation.
|
|
3637
|
-
/**
|
|
3638
|
-
* @internal
|
|
3639
|
-
* Builds an object with the required headers for a Transaction request. For Node
|
|
3640
|
-
*/
|
|
3641
|
-
function getTransactionHeaders(transactionGuid) {
|
|
3642
|
-
const baseHeaders = getBaseTransactionHeaders(transactionGuid);
|
|
3643
|
-
return Object.assign(Object.assign({}, baseHeaders), {
|
|
3644
|
-
// The below headers are not supported in the browser as they are flagged as "unsafe headers"
|
|
3645
|
-
"Accept-Charset": "UTF-8", Connection: "Keep-Alive" });
|
|
3646
|
-
}
|
|
3647
|
-
|
|
3648
3650
|
// Copyright (c) Microsoft Corporation.
|
|
3649
3651
|
/**
|
|
3650
3652
|
* Builds a transaction change set boundary to be added to the transaction request body
|
|
@@ -3744,21 +3746,6 @@ function getNextSubrequestBodyPart(request, changesetId) {
|
|
|
3744
3746
|
return subRequest.join(TRANSACTION_HTTP_LINE_ENDING);
|
|
3745
3747
|
}
|
|
3746
3748
|
|
|
3747
|
-
// Copyright (c) Microsoft Corporation.
|
|
3748
|
-
function isCosmosEndpoint(url) {
|
|
3749
|
-
const parsedURL = new url$1.URL(url);
|
|
3750
|
-
if (parsedURL.hostname.indexOf(".table.cosmosdb.") !== -1) {
|
|
3751
|
-
return true;
|
|
3752
|
-
}
|
|
3753
|
-
if (parsedURL.hostname.indexOf(".table.cosmos.") !== -1) {
|
|
3754
|
-
return true;
|
|
3755
|
-
}
|
|
3756
|
-
if (parsedURL.hostname === "localhost" && parsedURL.port !== "10002") {
|
|
3757
|
-
return true;
|
|
3758
|
-
}
|
|
3759
|
-
return false;
|
|
3760
|
-
}
|
|
3761
|
-
|
|
3762
3749
|
// Copyright (c) Microsoft Corporation.
|
|
3763
3750
|
// Licensed under the MIT license.
|
|
3764
3751
|
const cosmosPatchPolicyName = "cosmosPatchPolicy";
|
|
@@ -3775,6 +3762,49 @@ function cosmosPatchPolicy() {
|
|
|
3775
3762
|
};
|
|
3776
3763
|
}
|
|
3777
3764
|
|
|
3765
|
+
// Copyright (c) Microsoft Corporation.
|
|
3766
|
+
// Licensed under the MIT license.
|
|
3767
|
+
/**
|
|
3768
|
+
* @internal
|
|
3769
|
+
* Builds an object with the required headers for a Transaction request. For both Node and Browser
|
|
3770
|
+
*/
|
|
3771
|
+
function getBaseTransactionHeaders(transactionGuid) {
|
|
3772
|
+
return {
|
|
3773
|
+
accept: "application/json",
|
|
3774
|
+
"x-ms-version": "2019-02-02",
|
|
3775
|
+
DataServiceVersion: "3.0;",
|
|
3776
|
+
MaxDataServiceVersion: "3.0;NetFx",
|
|
3777
|
+
"Content-Type": `multipart/mixed; boundary=batch_${transactionGuid}`
|
|
3778
|
+
};
|
|
3779
|
+
}
|
|
3780
|
+
|
|
3781
|
+
// Copyright (c) Microsoft Corporation.
|
|
3782
|
+
/**
|
|
3783
|
+
* @internal
|
|
3784
|
+
* Builds an object with the required headers for a Transaction request. For Node
|
|
3785
|
+
*/
|
|
3786
|
+
function getTransactionHeaders(transactionGuid) {
|
|
3787
|
+
const baseHeaders = getBaseTransactionHeaders(transactionGuid);
|
|
3788
|
+
return Object.assign(Object.assign({}, baseHeaders), {
|
|
3789
|
+
// The below headers are not supported in the browser as they are flagged as "unsafe headers"
|
|
3790
|
+
"Accept-Charset": "UTF-8", Connection: "Keep-Alive" });
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3793
|
+
// Copyright (c) Microsoft Corporation.
|
|
3794
|
+
function isCosmosEndpoint(url) {
|
|
3795
|
+
const parsedURL = new url$1.URL(url);
|
|
3796
|
+
if (parsedURL.hostname.indexOf(".table.cosmosdb.") !== -1) {
|
|
3797
|
+
return true;
|
|
3798
|
+
}
|
|
3799
|
+
if (parsedURL.hostname.indexOf(".table.cosmos.") !== -1) {
|
|
3800
|
+
return true;
|
|
3801
|
+
}
|
|
3802
|
+
if (parsedURL.hostname === "localhost" && parsedURL.port !== "10002") {
|
|
3803
|
+
return true;
|
|
3804
|
+
}
|
|
3805
|
+
return false;
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3778
3808
|
// Copyright (c) Microsoft Corporation.
|
|
3779
3809
|
/**
|
|
3780
3810
|
* Helper to build a list of transaction actions
|
|
@@ -4074,6 +4104,34 @@ function base64Decode(value) {
|
|
|
4074
4104
|
return Buffer.from(value, "base64");
|
|
4075
4105
|
}
|
|
4076
4106
|
|
|
4107
|
+
// Copyright (c) Microsoft Corporation.
|
|
4108
|
+
/**
|
|
4109
|
+
* Encodes the nextPartitionKey and nextRowKey into a single continuation token
|
|
4110
|
+
*/
|
|
4111
|
+
function encodeContinuationToken(nextPartitionKey = "", nextRowKey = "") {
|
|
4112
|
+
if (!nextPartitionKey && !nextRowKey) {
|
|
4113
|
+
return undefined;
|
|
4114
|
+
}
|
|
4115
|
+
const continuationToken = JSON.stringify({
|
|
4116
|
+
nextPartitionKey,
|
|
4117
|
+
nextRowKey
|
|
4118
|
+
});
|
|
4119
|
+
return base64Encode(continuationToken);
|
|
4120
|
+
}
|
|
4121
|
+
/**
|
|
4122
|
+
* Decodes a continuationToken into an object containing a nextPartitionKey and nextRowKey
|
|
4123
|
+
*/
|
|
4124
|
+
function decodeContinuationToken(encodedToken) {
|
|
4125
|
+
const decodedToken = base64Decode(encodedToken);
|
|
4126
|
+
let tokenStr = "";
|
|
4127
|
+
for (const byte of decodedToken) {
|
|
4128
|
+
tokenStr += String.fromCharCode(byte);
|
|
4129
|
+
}
|
|
4130
|
+
const continuationToken = JSON.parse(tokenStr);
|
|
4131
|
+
return continuationToken;
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
// Copyright (c) Microsoft Corporation.
|
|
4077
4135
|
const propertyCaseMap = new Map([
|
|
4078
4136
|
["PartitionKey", "partitionKey"],
|
|
4079
4137
|
["RowKey", "rowKey"],
|
|
@@ -4293,33 +4351,6 @@ class Uuid {
|
|
|
4293
4351
|
}
|
|
4294
4352
|
}
|
|
4295
4353
|
|
|
4296
|
-
// Copyright (c) Microsoft Corporation.
|
|
4297
|
-
/**
|
|
4298
|
-
* Encodes the nextPartitionKey and nextRowKey into a single continuation token
|
|
4299
|
-
*/
|
|
4300
|
-
function encodeContinuationToken(nextPartitionKey = "", nextRowKey = "") {
|
|
4301
|
-
if (!nextPartitionKey && !nextRowKey) {
|
|
4302
|
-
return undefined;
|
|
4303
|
-
}
|
|
4304
|
-
const continuationToken = JSON.stringify({
|
|
4305
|
-
nextPartitionKey,
|
|
4306
|
-
nextRowKey
|
|
4307
|
-
});
|
|
4308
|
-
return base64Encode(continuationToken);
|
|
4309
|
-
}
|
|
4310
|
-
/**
|
|
4311
|
-
* Decodes a continuationToken into an object containing a nextPartitionKey and nextRowKey
|
|
4312
|
-
*/
|
|
4313
|
-
function decodeContinuationToken(encodedToken) {
|
|
4314
|
-
const decodedToken = base64Decode(encodedToken);
|
|
4315
|
-
let tokenStr = "";
|
|
4316
|
-
for (const byte of decodedToken) {
|
|
4317
|
-
tokenStr += String.fromCharCode(byte);
|
|
4318
|
-
}
|
|
4319
|
-
const continuationToken = JSON.parse(tokenStr);
|
|
4320
|
-
return continuationToken;
|
|
4321
|
-
}
|
|
4322
|
-
|
|
4323
4354
|
// Copyright (c) Microsoft Corporation.
|
|
4324
4355
|
// Licensed under the MIT license.
|
|
4325
4356
|
function escapeQuotesIfString(input, previous) {
|
|
@@ -4453,7 +4484,7 @@ class TableClient {
|
|
|
4453
4484
|
* // calling create table will create the table used
|
|
4454
4485
|
* // to instantiate the TableClient.
|
|
4455
4486
|
* // Note: If the table already
|
|
4456
|
-
* // exists this function doesn't
|
|
4487
|
+
* // exists this function doesn't throw.
|
|
4457
4488
|
* await client.createTable();
|
|
4458
4489
|
* ```
|
|
4459
4490
|
*/
|
|
@@ -4464,13 +4495,7 @@ class TableClient {
|
|
|
4464
4495
|
await this.table.create({ name: this.tableName }, updatedOptions);
|
|
4465
4496
|
}
|
|
4466
4497
|
catch (e) {
|
|
4467
|
-
|
|
4468
|
-
logger.info("TableClient-createTable: Table Already Exists");
|
|
4469
|
-
}
|
|
4470
|
-
else {
|
|
4471
|
-
span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message });
|
|
4472
|
-
throw e;
|
|
4473
|
-
}
|
|
4498
|
+
handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { span, logger, tableName: this.tableName }));
|
|
4474
4499
|
}
|
|
4475
4500
|
finally {
|
|
4476
4501
|
span.end();
|