@azure/cosmos 3.16.3-alpha.20220628.2 → 3.16.3
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 +3 -8
- package/dist/index.js +30 -23
- package/dist/index.js.map +1 -1
- package/dist/types/3.1/cosmos.d.ts +2 -0
- package/dist/types/latest/cosmos.d.ts +2 -0
- package/dist-esm/src/client/Item/Item.d.ts.map +1 -1
- package/dist-esm/src/client/Item/Item.js +13 -9
- package/dist-esm/src/client/Item/Item.js.map +1 -1
- package/dist-esm/src/common/constants.d.ts +2 -0
- package/dist-esm/src/common/constants.d.ts.map +1 -1
- package/dist-esm/src/common/constants.js +3 -0
- package/dist-esm/src/common/constants.js.map +1 -1
- package/dist-esm/src/common/helper.d.ts.map +1 -1
- package/dist-esm/src/common/helper.js +2 -13
- package/dist-esm/src/common/helper.js.map +1 -1
- package/dist-esm/src/utils/headers.js +12 -1
- package/dist-esm/src/utils/headers.js.map +1 -1
- package/dist-esm/src/utils/tracing.d.ts +2 -0
- package/dist-esm/src/utils/tracing.d.ts.map +1 -0
- package/dist-esm/src/utils/tracing.js +15 -0
- package/dist-esm/src/utils/tracing.js.map +1 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 3.16.3 (
|
|
4
|
-
|
|
5
|
-
### Features Added
|
|
6
|
-
|
|
7
|
-
### Breaking Changes
|
|
3
|
+
## 3.16.3 (2022-07-13)
|
|
8
4
|
|
|
9
5
|
### Bugs Fixed
|
|
10
|
-
|
|
11
|
-
### Other Changes
|
|
6
|
+
- Fixes issues with "id" encoding when using special characters that should be allowed in the "id" property of a document. [#22548](https://github.com/Azure/azure-sdk-for-js/pull/22548)
|
|
12
7
|
|
|
13
8
|
## 3.16.2 (2022-06-24)
|
|
14
9
|
|
|
15
10
|
### Bugs Fixed
|
|
16
|
-
-
|
|
11
|
+
- Adds support to run queries with group by over a column with null values. [#22345](https://github.com/Azure/azure-sdk-for-js/pull/22345)
|
|
17
12
|
|
|
18
13
|
## 3.16.1 (2022-05-31)
|
|
19
14
|
|
package/dist/index.js
CHANGED
|
@@ -174,7 +174,10 @@ const Constants = {
|
|
|
174
174
|
// Client generated retry count response header
|
|
175
175
|
ThrottleRetryCount: "x-ms-throttle-retry-count",
|
|
176
176
|
ThrottleRetryWaitTimeInMs: "x-ms-throttle-retry-wait-time-ms",
|
|
177
|
+
// Platform
|
|
177
178
|
CurrentVersion: "2020-07-15",
|
|
179
|
+
AzureNamespace: "Azure.Cosmos",
|
|
180
|
+
AzurePackageName: "@azure/cosmos",
|
|
178
181
|
SDKName: "azure-cosmos-js",
|
|
179
182
|
SDKVersion: "3.16.3",
|
|
180
183
|
Quota: {
|
|
@@ -561,17 +564,10 @@ function isResourceValid(resource, err) {
|
|
|
561
564
|
err.message = "Id must be a string.";
|
|
562
565
|
return false;
|
|
563
566
|
}
|
|
564
|
-
if (resource.id.indexOf("/") !== -1 ||
|
|
565
|
-
resource.id.indexOf("\\") !== -1 ||
|
|
566
|
-
resource.id.indexOf("?") !== -1 ||
|
|
567
|
-
resource.id.indexOf("#") !== -1) {
|
|
567
|
+
if (resource.id.indexOf("/") !== -1 || resource.id.indexOf("\\") !== -1) {
|
|
568
568
|
err.message = "Id contains illegal chars.";
|
|
569
569
|
return false;
|
|
570
570
|
}
|
|
571
|
-
if (resource.id[resource.id.length - 1] === " ") {
|
|
572
|
-
err.message = "Id ends with a space.";
|
|
573
|
-
return false;
|
|
574
|
-
}
|
|
575
571
|
}
|
|
576
572
|
return true;
|
|
577
573
|
}
|
|
@@ -614,13 +610,9 @@ function validateResourceId(resourceId) {
|
|
|
614
610
|
if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) {
|
|
615
611
|
throw new Error("Resource Id must be a string and cannot be undefined, null or empty");
|
|
616
612
|
}
|
|
617
|
-
// if resourceId starts or ends with space throw an error
|
|
618
|
-
if (resourceId[resourceId.length - 1] === " ") {
|
|
619
|
-
throw new Error("Resource Id cannot end with space");
|
|
620
|
-
}
|
|
621
613
|
// if resource id contains illegal characters throw an error
|
|
622
614
|
if (illegalResourceIdCharacters.test(resourceId)) {
|
|
623
|
-
throw new Error("Illegal characters ['/', '\\'
|
|
615
|
+
throw new Error("Illegal characters ['/', '\\'] cannot be used in resourceId");
|
|
624
616
|
}
|
|
625
617
|
return true;
|
|
626
618
|
}
|
|
@@ -916,6 +908,17 @@ async function generateHeaders(masterKey, method, resourceType = exports.Resourc
|
|
|
916
908
|
[Constants.HttpHeaders.XDate]: date.toUTCString(),
|
|
917
909
|
};
|
|
918
910
|
}
|
|
911
|
+
function getEffectiveResourceIdForSignature(resourceId) {
|
|
912
|
+
const lastSlashPosition = resourceId.lastIndexOf("/");
|
|
913
|
+
if (lastSlashPosition <= 0) {
|
|
914
|
+
return resourceId;
|
|
915
|
+
}
|
|
916
|
+
const prefix = resourceId.substring(0, lastSlashPosition);
|
|
917
|
+
if (!prefix.endsWith("/docs")) {
|
|
918
|
+
return resourceId;
|
|
919
|
+
}
|
|
920
|
+
return prefix + "/" + decodeURIComponent(resourceId.substring(lastSlashPosition + 1));
|
|
921
|
+
}
|
|
919
922
|
async function signature(masterKey, method, resourceType, resourceId = "", date = new Date()) {
|
|
920
923
|
const type = "master";
|
|
921
924
|
const version = "1.0";
|
|
@@ -923,7 +926,7 @@ async function signature(masterKey, method, resourceType, resourceId = "", date
|
|
|
923
926
|
"\n" +
|
|
924
927
|
resourceType.toLowerCase() +
|
|
925
928
|
"\n" +
|
|
926
|
-
resourceId +
|
|
929
|
+
getEffectiveResourceIdForSignature(resourceId) +
|
|
927
930
|
"\n" +
|
|
928
931
|
date.toUTCString().toLowerCase() +
|
|
929
932
|
"\n" +
|
|
@@ -4369,7 +4372,7 @@ class Item {
|
|
|
4369
4372
|
* Returns a reference URL to the resource. Used for linking in Permissions.
|
|
4370
4373
|
*/
|
|
4371
4374
|
get url() {
|
|
4372
|
-
return createDocumentUri(this.container.database.id, this.container.id, this.id);
|
|
4375
|
+
return createDocumentUri(this.container.database.id, this.container.id, encodeURIComponent(this.id));
|
|
4373
4376
|
}
|
|
4374
4377
|
/**
|
|
4375
4378
|
* Read the item's definition.
|
|
@@ -4400,8 +4403,9 @@ class Item {
|
|
|
4400
4403
|
const { resource: partitionKeyDefinition } = await this.container.readPartitionKeyDefinition();
|
|
4401
4404
|
this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);
|
|
4402
4405
|
}
|
|
4403
|
-
const
|
|
4404
|
-
const
|
|
4406
|
+
const resourceUri = this.url;
|
|
4407
|
+
const path = getPathFromLink(resourceUri);
|
|
4408
|
+
const id = getIdFromLink(resourceUri);
|
|
4405
4409
|
let response;
|
|
4406
4410
|
try {
|
|
4407
4411
|
response = await this.clientContext.read({
|
|
@@ -4429,8 +4433,9 @@ class Item {
|
|
|
4429
4433
|
if (!isResourceValid(body, err)) {
|
|
4430
4434
|
throw err;
|
|
4431
4435
|
}
|
|
4432
|
-
const
|
|
4433
|
-
const
|
|
4436
|
+
const resourceUri = this.url;
|
|
4437
|
+
const path = getPathFromLink(resourceUri);
|
|
4438
|
+
const id = getIdFromLink(resourceUri);
|
|
4434
4439
|
const response = await this.clientContext.replace({
|
|
4435
4440
|
body,
|
|
4436
4441
|
path,
|
|
@@ -4454,8 +4459,9 @@ class Item {
|
|
|
4454
4459
|
const { resource: partitionKeyDefinition } = await this.container.readPartitionKeyDefinition();
|
|
4455
4460
|
this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);
|
|
4456
4461
|
}
|
|
4457
|
-
const
|
|
4458
|
-
const
|
|
4462
|
+
const resourceUri = this.url;
|
|
4463
|
+
const path = getPathFromLink(resourceUri);
|
|
4464
|
+
const id = getIdFromLink(resourceUri);
|
|
4459
4465
|
const response = await this.clientContext.delete({
|
|
4460
4466
|
path,
|
|
4461
4467
|
resourceType: exports.ResourceType.item,
|
|
@@ -4478,8 +4484,9 @@ class Item {
|
|
|
4478
4484
|
const { resource: partitionKeyDefinition } = await this.container.readPartitionKeyDefinition();
|
|
4479
4485
|
this.partitionKey = extractPartitionKey(body, partitionKeyDefinition);
|
|
4480
4486
|
}
|
|
4481
|
-
const
|
|
4482
|
-
const
|
|
4487
|
+
const resourceUri = this.url;
|
|
4488
|
+
const path = getPathFromLink(resourceUri);
|
|
4489
|
+
const id = getIdFromLink(resourceUri);
|
|
4483
4490
|
const response = await this.clientContext.patch({
|
|
4484
4491
|
body,
|
|
4485
4492
|
path,
|