@azure/data-tables 12.2.0-alpha.20211102.1 → 13.0.0-alpha.20211111.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 CHANGED
@@ -1,17 +1,24 @@
1
1
  # Release History
2
2
 
3
- ## 12.2.0 (Unreleased)
3
+ ## 13.0.0 (2021-11-09)
4
4
 
5
5
  ### Features Added
6
- - Take `continuationToken` as a `PageSetting` and expose it in the page when listing entities `byPage`. [#18179](https://github.com/Azure/azure-sdk-for-js/pull/18179)
6
+
7
+ - TableClient `listEntities` expose and can take as PageSetting `continuationToken` as a `PageSetting` when using `byPage`. [#18179](https://github.com/Azure/azure-sdk-for-js/pull/18179)
8
+ - TableServiceClient `listTables` expose and can take PageSetting `continuationToken` as a `PageSetting` when using `byPage`. [#18277](https://github.com/Azure/azure-sdk-for-js/pull/18277)
7
9
 
8
10
  ### Breaking Changes
9
11
 
12
+ - Encode single quote where the partition/row key is used to format the URL - i.e. upsert, update and delete. For more details see Issue [#3356](https://github.com/Azure/azure-sdk/issues/3356). Fixed in [#18520](https://github.com/Azure/azure-sdk-for-js/pull/18520)
13
+ - Setting a binary property on an entity without automatic type conversion takes raw string instead of Uint8Array [#18251](https://github.com/Azure/azure-sdk-for-js/pull/18251)
14
+
10
15
  ### Bugs Fixed
16
+
11
17
  - Document usage of SDK with Azurite. [#18211](https://github.com/Azure/azure-sdk-for-js/pull/18211)
12
18
  - Issue #17407 - Correctly handle etag in select filter. [#18211](https://github.com/Azure/azure-sdk-for-js/pull/18211)
13
- - Issue #18079 - Correctly handle creating entities with properties containing empty strings "". Fixes Insert throws "Unknown EDM type object" error with property value { value: "", type: "String" }. [#18211](https://github.com/Azure/azure-sdk-for-js/pull/18211)
19
+ - Issue #18079 - Correctly handle creating entities with properties containing empty strings "". Fixes Insert throws "Unknown EDM type object" error with property value { value: "", type: "String" }. [#18211](https://github.com/Azure/azure-sdk-for-js/pull/18211)
14
20
  - Issue #18148 - Correctly deserialize Decimal numbers checking for isSafeInteger. Fixes listEntities always returns an Int32 type for a value of "1.23456789012346e+24". [#18211](https://github.com/Azure/azure-sdk-for-js/pull/18211)
21
+ - Issue #18521 - `upsertEntity` doesn't work with "" for partition or row keys. [#18586](https://github.com/Azure/azure-sdk-for-js/pull/18586)
15
22
 
16
23
  ### Other Changes
17
24
 
package/dist/index.js CHANGED
@@ -3068,7 +3068,7 @@ class GeneratedClientContext extends coreClient.ServiceClient {
3068
3068
  const defaults = {
3069
3069
  requestContentType: "application/json; charset=utf-8"
3070
3070
  };
3071
- const packageDetails = `azsdk-js-data-tables/12.2.0`;
3071
+ const packageDetails = `azsdk-js-data-tables/13.0.0`;
3072
3072
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
3073
3073
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
3074
3074
  : `${packageDetails}`;
@@ -3534,6 +3534,9 @@ class TableServiceClient {
3534
3534
  },
3535
3535
  byPage: (settings) => {
3536
3536
  const pageOptions = Object.assign(Object.assign({}, options), { queryOptions: { top: settings === null || settings === void 0 ? void 0 : settings.maxPageSize } });
3537
+ if (settings === null || settings === void 0 ? void 0 : settings.continuationToken) {
3538
+ pageOptions.continuationToken = settings.continuationToken;
3539
+ }
3537
3540
  return this.listTablesPage(pageOptions);
3538
3541
  }
3539
3542
  };
@@ -3542,10 +3545,10 @@ class TableServiceClient {
3542
3545
  return tslib.__asyncGenerator(this, arguments, function* listTablesAll_1() {
3543
3546
  var e_1, _a;
3544
3547
  const firstPage = yield tslib.__await(this._listTables(options));
3545
- const { nextTableName } = firstPage;
3548
+ const { continuationToken } = firstPage;
3546
3549
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(firstPage)));
3547
- if (nextTableName) {
3548
- const optionsWithContinuation = Object.assign(Object.assign({}, options), { nextTableName });
3550
+ if (continuationToken) {
3551
+ const optionsWithContinuation = Object.assign(Object.assign({}, options), { continuationToken });
3549
3552
  try {
3550
3553
  for (var _b = tslib.__asyncValues(this.listTablesPage(optionsWithContinuation)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
3551
3554
  const page = _c.value;
@@ -3568,8 +3571,8 @@ class TableServiceClient {
3568
3571
  try {
3569
3572
  let result = yield tslib.__await(this._listTables(updatedOptions));
3570
3573
  yield yield tslib.__await(result);
3571
- while (result.nextTableName) {
3572
- const optionsWithContinuation = Object.assign(Object.assign({}, updatedOptions), { nextTableName: result.nextTableName });
3574
+ while (result.continuationToken) {
3575
+ const optionsWithContinuation = Object.assign(Object.assign({}, updatedOptions), { continuationToken: result.continuationToken });
3573
3576
  result = yield tslib.__await(this._listTables(optionsWithContinuation));
3574
3577
  yield yield tslib.__await(result);
3575
3578
  }
@@ -3583,9 +3586,10 @@ class TableServiceClient {
3583
3586
  }
3584
3587
  });
3585
3588
  }
3586
- async _listTables(options) {
3587
- const { xMsContinuationNextTableName: nextTableName, value = [] } = await this.table.query(options);
3588
- return Object.assign([...value], { nextTableName });
3589
+ async _listTables(options = {}) {
3590
+ const { continuationToken: nextTableName } = options, listOptions = tslib.__rest(options, ["continuationToken"]);
3591
+ const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query(Object.assign(Object.assign({}, listOptions), { nextTableName }));
3592
+ return Object.assign([...value], { continuationToken });
3589
3593
  }
3590
3594
  /**
3591
3595
  *
@@ -4120,14 +4124,11 @@ function serializeObject(obj) {
4120
4124
  obj.type === "Guid" ||
4121
4125
  obj.type === "Int32" ||
4122
4126
  obj.type === "Int64" ||
4123
- obj.type === "String") {
4127
+ obj.type === "String" ||
4128
+ obj.type === "Binary") {
4124
4129
  serializedValue.value = obj.value;
4125
4130
  serializedValue.type = Edm[obj.type];
4126
4131
  }
4127
- else if (obj.type === "Binary") {
4128
- serializedValue.value = base64Encode(obj.value);
4129
- serializedValue.type = Edm.Binary;
4130
- }
4131
4132
  else {
4132
4133
  throw new Error(`Unknown EDM type ${typeof obj.value}`);
4133
4134
  }
@@ -4319,6 +4320,36 @@ function decodeContinuationToken(encodedToken) {
4319
4320
  return continuationToken;
4320
4321
  }
4321
4322
 
4323
+ // Copyright (c) Microsoft Corporation.
4324
+ // Licensed under the MIT license.
4325
+ function escapeQuotesIfString(input, previous) {
4326
+ let result = input;
4327
+ if (typeof input === "string") {
4328
+ result = escapeQuotes(input);
4329
+ // check if we need to escape this literal
4330
+ if (!previous.trim().endsWith("'")) {
4331
+ result = `'${result}'`;
4332
+ }
4333
+ }
4334
+ return result;
4335
+ }
4336
+ function escapeQuotes(input) {
4337
+ return input.replace(/'/g, "''");
4338
+ }
4339
+ /**
4340
+ * Escapes an odata filter expression to avoid errors with quoting string literals.
4341
+ */
4342
+ function odata(strings, ...values) {
4343
+ const results = [];
4344
+ for (let i = 0; i < strings.length; i++) {
4345
+ results.push(strings[i]);
4346
+ if (i < values.length) {
4347
+ results.push(escapeQuotesIfString(values[i], strings[i]));
4348
+ }
4349
+ }
4350
+ return results.join("");
4351
+ }
4352
+
4322
4353
  // Copyright (c) Microsoft Corporation.
4323
4354
  /**
4324
4355
  * A TableClient represents a Client to the Azure Tables service allowing you
@@ -4485,7 +4516,7 @@ class TableClient {
4485
4516
  }
4486
4517
  try {
4487
4518
  const _a = updatedOptions || {}, { disableTypeConversion, queryOptions } = _a, getEntityOptions = tslib.__rest(_a, ["disableTypeConversion", "queryOptions"]);
4488
- await this.table.queryEntitiesWithPartitionAndRowKey(this.tableName, partitionKey, rowKey, Object.assign(Object.assign({}, getEntityOptions), { queryOptions: serializeQueryOptions(queryOptions || {}), onResponse }));
4519
+ await this.table.queryEntitiesWithPartitionAndRowKey(this.tableName, escapeQuotes(partitionKey), escapeQuotes(rowKey), Object.assign(Object.assign({}, getEntityOptions), { queryOptions: serializeQueryOptions(queryOptions || {}), onResponse }));
4489
4520
  const tableEntity = deserialize(parsedBody, disableTypeConversion !== null && disableTypeConversion !== void 0 ? disableTypeConversion : false);
4490
4521
  return tableEntity;
4491
4522
  }
@@ -4687,7 +4718,7 @@ class TableClient {
4687
4718
  try {
4688
4719
  const _a = updatedOptions || {}, { etag = "*" } = _a, rest = tslib.__rest(_a, ["etag"]);
4689
4720
  const deleteOptions = Object.assign({}, rest);
4690
- return await this.table.deleteEntity(this.tableName, partitionKey, rowKey, etag, deleteOptions);
4721
+ return await this.table.deleteEntity(this.tableName, escapeQuotes(partitionKey), escapeQuotes(rowKey), etag, deleteOptions);
4691
4722
  }
4692
4723
  catch (e) {
4693
4724
  span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message });
@@ -4741,15 +4772,14 @@ class TableClient {
4741
4772
  options = {}) {
4742
4773
  const { span, updatedOptions } = createSpan(`TableClient-updateEntity-${mode}`, options);
4743
4774
  try {
4744
- if (!entity.partitionKey || !entity.rowKey) {
4745
- throw new Error("partitionKey and rowKey must be defined");
4746
- }
4775
+ const partitionKey = escapeQuotes(entity.partitionKey);
4776
+ const rowKey = escapeQuotes(entity.rowKey);
4747
4777
  const _a = updatedOptions || {}, { etag = "*" } = _a, updateEntityOptions = tslib.__rest(_a, ["etag"]);
4748
4778
  if (mode === "Merge") {
4749
- return await this.table.mergeEntity(this.tableName, entity.partitionKey, entity.rowKey, Object.assign({ tableEntityProperties: serialize(entity), ifMatch: etag }, updateEntityOptions));
4779
+ return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, Object.assign({ tableEntityProperties: serialize(entity), ifMatch: etag }, updateEntityOptions));
4750
4780
  }
4751
4781
  if (mode === "Replace") {
4752
- return await this.table.updateEntity(this.tableName, entity.partitionKey, entity.rowKey, Object.assign({ tableEntityProperties: serialize(entity), ifMatch: etag }, updateEntityOptions));
4782
+ return await this.table.updateEntity(this.tableName, partitionKey, rowKey, Object.assign({ tableEntityProperties: serialize(entity), ifMatch: etag }, updateEntityOptions));
4753
4783
  }
4754
4784
  throw new Error(`Unexpected value for update mode: ${mode}`);
4755
4785
  }
@@ -4801,14 +4831,13 @@ class TableClient {
4801
4831
  options = {}) {
4802
4832
  const { span, updatedOptions } = createSpan(`TableClient-upsertEntity-${mode}`, options);
4803
4833
  try {
4804
- if (!entity.partitionKey || !entity.rowKey) {
4805
- throw new Error("partitionKey and rowKey must be defined");
4806
- }
4834
+ const partitionKey = escapeQuotes(entity.partitionKey);
4835
+ const rowKey = escapeQuotes(entity.rowKey);
4807
4836
  if (mode === "Merge") {
4808
- return await this.table.mergeEntity(this.tableName, entity.partitionKey, entity.rowKey, Object.assign({ tableEntityProperties: serialize(entity) }, updatedOptions));
4837
+ return await this.table.mergeEntity(this.tableName, partitionKey, rowKey, Object.assign({ tableEntityProperties: serialize(entity) }, updatedOptions));
4809
4838
  }
4810
4839
  if (mode === "Replace") {
4811
- return await this.table.updateEntity(this.tableName, entity.partitionKey, entity.rowKey, Object.assign({ tableEntityProperties: serialize(entity) }, updatedOptions));
4840
+ return await this.table.updateEntity(this.tableName, partitionKey, rowKey, Object.assign({ tableEntityProperties: serialize(entity) }, updatedOptions));
4812
4841
  }
4813
4842
  throw new Error(`Unexpected value for update mode: ${mode}`);
4814
4843
  }
@@ -4948,33 +4977,6 @@ class TableClient {
4948
4977
  }
4949
4978
  }
4950
4979
 
4951
- // Copyright (c) Microsoft Corporation.
4952
- // Licensed under the MIT license.
4953
- function escapeQuotesIfString(input, previous) {
4954
- let result = input;
4955
- if (typeof input === "string") {
4956
- result = input.replace(/'/g, "''");
4957
- // check if we need to escape this literal
4958
- if (!previous.trim().endsWith("'")) {
4959
- result = `'${result}'`;
4960
- }
4961
- }
4962
- return result;
4963
- }
4964
- /**
4965
- * Escapes an odata filter expression to avoid errors with quoting string literals.
4966
- */
4967
- function odata(strings, ...values) {
4968
- const results = [];
4969
- for (let i = 0; i < strings.length; i++) {
4970
- results.push(strings[i]);
4971
- if (i < values.length) {
4972
- results.push(escapeQuotesIfString(values[i], strings[i]));
4973
- }
4974
- }
4975
- return results.join("");
4976
- }
4977
-
4978
4980
  Object.defineProperty(exports, 'AzureNamedKeyCredential', {
4979
4981
  enumerable: true,
4980
4982
  get: function () {