From bf3c15be99191513bb7590b24e1b49506ab9b898 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Thu, 21 Nov 2019 09:01:09 -0600 Subject: [PATCH] [Cosmos] Make changeFeed and query options optional. Fix #6232 Fix #6277 (#6258) --- sdk/cosmosdb/cosmos/changelog.md | 4 ++++ sdk/cosmosdb/cosmos/review/cosmos.api.md | 10 +++++----- sdk/cosmosdb/cosmos/src/client/Item/Items.ts | 12 ++++++------ .../{incrementalFeed.spec.ts => changeFeed.spec.ts} | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) rename sdk/cosmosdb/cosmos/test/integration/{incrementalFeed.spec.ts => changeFeed.spec.ts} (98%) diff --git a/sdk/cosmosdb/cosmos/changelog.md b/sdk/cosmosdb/cosmos/changelog.md index eb194d9d86b3..477a346ce2b4 100644 --- a/sdk/cosmosdb/cosmos/changelog.md +++ b/sdk/cosmosdb/cosmos/changelog.md @@ -1,3 +1,7 @@ +## 3.4.3 + +- Makes changeFeed and query options optional. Fix #6232 Fix #6277 (#6273) + ## 3.4.2 - Fixes bug where the query may throw a 410 error during a split operation. Instead, throw 503 (#6074) diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index 8d2364ec1888..3db752ccb9c5 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -561,26 +561,26 @@ export class ItemResponse extends ResourceResponse; + changeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; - changeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator; + changeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; // (undocumented) readonly container: Container; create(body: T, options?: RequestOptions): Promise>; query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; - query(query: string | SqlQuerySpec, options: FeedOptions): QueryIterator; + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; readAll(options?: FeedOptions): QueryIterator; readAll(options?: FeedOptions): QueryIterator; // Warning: (ae-forgotten-export) The symbol "ChangeFeedOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ChangeFeedIterator" needs to be exported by the entry point index.d.ts // // @deprecated - readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator; + readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; // @deprecated readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; // @deprecated - readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator; + readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; // @deprecated readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; upsert(body: any, options?: RequestOptions): Promise>; diff --git a/sdk/cosmosdb/cosmos/src/client/Item/Items.ts b/sdk/cosmosdb/cosmos/src/client/Item/Items.ts index 1d4e0ea22f6d..b1ad79769b97 100644 --- a/sdk/cosmosdb/cosmos/src/client/Item/Items.ts +++ b/sdk/cosmosdb/cosmos/src/client/Item/Items.ts @@ -72,7 +72,7 @@ export class Items { * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll(); * ``` */ - public query(query: string | SqlQuerySpec, options: FeedOptions): QueryIterator; + public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; public query(query: string | SqlQuerySpec, options: FeedOptions = {}): QueryIterator { const path = getPathFromLink(this.container.url, ResourceType.item); const id = getIdFromLink(this.container.url); @@ -115,7 +115,7 @@ export class Items { */ public readChangeFeed( partitionKey: string | number | boolean, - changeFeedOptions: ChangeFeedOptions + changeFeedOptions?: ChangeFeedOptions ): ChangeFeedIterator; /** * Create a `ChangeFeedIterator` to iterate over pages of changes @@ -133,7 +133,7 @@ export class Items { */ public readChangeFeed( partitionKey: string | number | boolean, - changeFeedOptions: ChangeFeedOptions + changeFeedOptions?: ChangeFeedOptions ): ChangeFeedIterator; /** * Create a `ChangeFeedIterator` to iterate over pages of changes @@ -169,7 +169,7 @@ export class Items { */ public changeFeed( partitionKey: string | number | boolean, - changeFeedOptions: ChangeFeedOptions + changeFeedOptions?: ChangeFeedOptions ): ChangeFeedIterator; /** * Create a `ChangeFeedIterator` to iterate over pages of changes @@ -185,7 +185,7 @@ export class Items { */ public changeFeed( partitionKey: string | number | boolean, - changeFeedOptions: ChangeFeedOptions + changeFeedOptions?: ChangeFeedOptions ): ChangeFeedIterator; /** * Create a `ChangeFeedIterator` to iterate over pages of changes @@ -209,7 +209,7 @@ export class Items { } if (!changeFeedOptions) { - throw new Error("changeFeedOptions must be a valid object"); + changeFeedOptions = {}; } const path = getPathFromLink(this.container.url, ResourceType.item); diff --git a/sdk/cosmosdb/cosmos/test/integration/incrementalFeed.spec.ts b/sdk/cosmosdb/cosmos/test/integration/changeFeed.spec.ts similarity index 98% rename from sdk/cosmosdb/cosmos/test/integration/incrementalFeed.spec.ts rename to sdk/cosmosdb/cosmos/test/integration/changeFeed.spec.ts index 2fd900b0f6a9..f6afbc8c0659 100644 --- a/sdk/cosmosdb/cosmos/test/integration/incrementalFeed.spec.ts +++ b/sdk/cosmosdb/cosmos/test/integration/changeFeed.spec.ts @@ -107,7 +107,7 @@ describe("Change Feed Iterator", function() { }); it("should fetch new items only", async function() { - const iterator = container.items.changeFeed("0", {}); + const iterator = container.items.changeFeed("0"); const { result: items, headers } = await iterator.fetchNext(); assert(headers.etag, "change feed response should have etag header");